amit
amit

Reputation: 39

JSON Exceptionorg.json.JSONException: Unterminated string at character

Im unable to get complete JSON string, it doesn't show last three character if the string. Here is JSON String

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

JSON request

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 {
                        }

Error log

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

Upvotes: 0

Views: 868

Answers (1)

Ricardo Vieira
Ricardo Vieira

Reputation: 1818

You are getting that error because the JSON Object appears to be incomplete (according do your code snippet). If the string composing the JSON is incomplete, it will cause a JSON Parsing Exception

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

Should instead be :

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

Upvotes: 1

Related Questions