java - How to resolve, JSONException: No value for "1" -
been looking around on site while, , i'm not getting anywhere.
i creating android app getting list of values mysql db via php, , returning result encoded in json object:
{"error":false,"values":{"1":{"name":"this string"}, "2":{...}}}
i retrieving json object in java so:
jsonobject jobj = new jsonobject(response); boolean error = jobj.getboolean("error"); if (!error) { jsonobject values = jobj.getjsonobject("values"); iterator<?> keys = values.keys(); while(keys.hasnext()) { string key = (string)keys.next(); jsonobject value = jobj.getjsonobject(key); ... }
its @ point before ellipses exception:
org.json.jsonexception: no value "1"
am doing stupid, or what, looks ok me. have tried multiple different things keep getting same issue. name obj , add list of strings. can't seem beyond point.
any or push in right direction grateful.
jsonobject value = jobj.getjsonobject(key);
replace with
jsonobject value = values.getjsonobject(key);
Comments
Post a Comment