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?
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");
}
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’ll enjoy: Parks, playgrounds\"}]
This will do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With