Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Org.json.JSONException: Unterminated string at character 1834 [closed]

Tags:

java

json

android

I am fetching the data from webservice, which I am parsing to JSON string. While parsing I am this exception: "org.json.JSONException: Unterminated string at character 1834"

my code is,

String jsonstring=getJSONString(response);

JSONObject json = new JSONObject(jsonstring);

The string is,

[{"LotDescription":"David Weekley homes Traditional Collection in Baxter Village offers floor plans featuring innovative design and unsurpassed quality. This charming community combines work, play and living, all within the Village. In Baxter Village, you’ll enjoy:  Parks, playgrounds"}]

It is parsing till the word "Village" and the raising the exception while parsing " you’ll " which seems to be some HTML content.

What is the solution for this?

like image 590
Mahe Avatar asked May 21 '13 07:05

Mahe


2 Answers

Your Json is not an JSONObject but a JSONArray.
Try this instead:

JSONArray jObject = new JSONArray(jsonstring);
        for (int i = 0; i < jObject.length(); i++) {
             JSONObject object = jObject.getJSONObject(i);

             String LotDescription = menuObject.getString("LotDescription");
         }
like image 157
Lazy Ninja Avatar answered Nov 16 '22 04:11

Lazy Ninja


You need to add character \.

[{"LotDescription":\"David Weekley homes Traditional Collection in Baxter Village offers floor plans featuring innovative design and unsurpassed quality. This charming community combines work, play and living, all within the Village. In Baxter Village, you&rsquo;ll enjoy:&nbsp; Parks, playgrounds\"}]

This will do.

like image 40
Shreyos Adikari Avatar answered Nov 16 '22 06:11

Shreyos Adikari