While i’m working with long JSON strings(5018 characters)
I’ve encountered the following exception:
09-15 19:41:40.821: W/System.err(1551): org.json.JSONException: Value [{/* my long json string...... */
09-15 19:41:40.831: W/System.err(1551): at org.json.JSON.typeMismatch(JSON.java:111)
09-15 19:41:40.831: W/System.err(1551): at org.json.JSONObject.<init>(JSONObject.java:158)
09-15 19:41:40.831: W/System.err(1551): at org.json.JSONObject.<init>(JSONObject.java:171)
I’ve noticed that the string displayed in org.json.JSONException: Value [....] is only 4052 characters long(could be logcat’s character limitation, I’m not sure).
here’s my code:
public DrupalNode getNode() {
JSONObject drupalJSON;
Log.d(TAG, "Length: "+drupalReturn.length());
try {
Log.d(TAG, "JSON data: "+this.drupalReturn);
drupalJSON = new JSONObject(this.drupalReturn);
DrupalNode drupalNode = new DrupalNode();
drupalNode.title = drupalJSON.getString("title");
return drupalNode;
} catch (JSONException e) {
Log.e(TAG, "JSON decode error");
e.printStackTrace();
return null;
}
}
I’ve tried JSON strings with >=2000 characters with no problem….
Is the JSONObject truncating my JSON string? how do I fix this?
Can you provide your json data here. It’s difficult to answer your question with out the json.
With the error itself showing the empty array as your json string content is
commented.I guess your JSON format is an
JSONArraynotJSONObject. Please check it. or Share your json file.