Org.json.JSONException: string with an inexhaustible character 1834

I am extracting data from webservice which I am processing in a JSON string. During parsing, I am this exception: "org.json.JSONException: Unterminated string at character 1834"

my code

String jsonstring=getJSONString(response); JSONObject json = new JSONObject(jsonstring); 

Line:

 [{"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 parses to the word "Village" and raises an exception when parsing "you & rsquo; ll", which seems to be some HTML content.

What is the solution for this?

+7
source share
2 answers

You need to add the \ 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’ll enjoy:  Parks, playgrounds\"}] 

It will do.

+2
source

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

 JSONArray jObject = new JSONArray(jsonstring); for (int i = 0; i < jObject.length(); i++) { JSONObject object = jObject.getJSONObject(i); String LotDescription = menuObject.getString("LotDescription"); } 
+1
source

All Articles