JSON Exceptionorg.json.JSONException:字符处未终止的字符串

时间:2016-07-26 08:42:56

标签: json numberformatexception

我无法获得完整的JSON字符串,如果字符串,它不会显示最后三个字符。这是JSON字符串

{"status":"success","data":"Screenshot_2016-07-24-13-06-4120160726082711.pn 

JSON请求

StringRequest stringRequest = new StringRequest(Request.Method.POST,
                url, new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                try {
                    Utils.psLog("Server RESPONSE >> " + response);
                    JSONObject obj = new JSONObject(response);
                        }
                       catch {
                        }

错误日志

07-26 13:57:11.556 8632-8632/com.directory D/TEAMPS: Server RESPONSE >> 


                                                                       {"status":"success","data":"Screenshot_2016-07-24-13-06-4120160726082711.pn
07-26 13:57:11.557 8632-8632/com.directory D/TEAMPS: JSON Exceptionorg.json.JSONException: Unterminated string at character 78 of 


                                                                       {"status":"success","data":"Screenshot_2016-07-24-13-06-4120160726082711.pn

1 个答案:

答案 0 :(得分:1)

您收到该错误是因为 JSON对象似乎不完整(根据您的代码段)。 如果组成JSON的字符串不完整,则会导致JSON解析异常

{"status":"success","data":"Screenshot_2016-07-24-13-06-4120160726082711.pn 

应改为:

{"status":"success","data":"Screenshot_2016-07-24-13-06-4120160726082711.png"}