I have the following string which (as far as I know) is in a valid format
[
{
"name":"John Doe"
},
{
"name":"Jane Doe"
}
]
After calling the following:
return new JSONArray(jsonString);
With jsonString being the JSON given above. I get the following error:
org.json.JSONException: Value jsonString of type java.lang.String cannot be converted to JSONArray
Any ideas why the parser won't accept the string?
Edit
The problem has been solved. The array was encoded as a string in the JSON output. I first retrieved the string with the getString(param) method instead of trying to convert it directly with getJsonArray, then converted the string to the json array.
Stringvariable? I just tried putting your JSON into aStringand escaping all the quotes, and it worked. Also what version oforg.json.jsonare you using?data. First, I convert the entire JSON block to aJSONObject. After that, I try to get the array under the keydataby callinggetJSONArray("data"). The string is escaped correctly.String.