如何调试“ org.json.JsonException:第2个字符的输入结束”

时间:2019-09-26 16:38:08

标签: android android-volley

我正在使用VolleyNetwork的JsonObjectRequest发送http请求。我得到了响应errorlistener as exception as org.json.JsonException: end of input at character 2 of,有时还得到了预期的输出(消息),如何找到问题所在?

private void sendDataSimulatneouslyforload(final String val, final String value1, String params)
{

    if (!val.equals("") && !value1.equals("") && !params.equals("")) {
        urls = "http://192.168.3.8/QRSCAN/tempdata.jsp?value=" + val + "&details=" + params;

        Log.d("timeload", " " + Calendar.getInstance().getTimeInMillis());

        jsonObjectRequest12 = new JsonObjectRequest(Request.Method.GET, urls, null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                try {

                    String message = response.getString("response");

                    calladdData2(val, value1, message);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

                Log.d("INVTAG", error.getMessage());

            }
        });
        SingleTonClass.getInstance(ScanningLoad.this).addToRequestQueue(jsonObjectRequest12, "TAG");
    }else {
        makeText(getApplicationContext(), "Scan Again", LENGTH_SHORT).show();
    } 

0 个答案:

没有答案