Reputation: 7230
I'm trying to play around with Android development, but I can't seem to get passed this error when I try to parse some JSON coming from an API:
org.json.JSONException: Value true at 0 of type java.lang.Boolean cannot be converted to JSONObject
So, it can't handle "true"? That just seems silly. Here's the first part of the response, where it's failing:
[true,{"total":84,"results": ...
And here's how I'm trying to do the parsing:
new JSONArray(json);
Upvotes: 0
Views: 2413
Reputation: 126533
Hi Phil this is an example...
int mytotal;
if (result instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) result;
JSONObject jo = jsonArray.getJSONObject(0);
mytotal = jo.getInt("total");
}
Upvotes: 1