java - JSON Exception String cannot be converted to JSON Object -


i trying parse json , running small problem.

my json string looks this:

string json =     [         "{caption=blah, url=/storage/emulated/0/dcim/camera/20140331_164648.jpg}",         "{caption=adsf, url=/storage/emulated/0/dcim/camera/20140330_103412.jpg}"     ] 

and code far looks this:

try { jsonarray jsonobj = new jsonarray(json);  (int = 0; < jsonobj.length(); i++) {     jsonobject c = jsonobj.getjsonobject(i);        string img = c.getstring("url");     string cap = c.getstring("caption"); 

but throwing exception type java.lang.string cannot converted jsonobject

what doing wrong?

edit

if helpful anyone, ended using gson json in correct expected format this:

gson gson = new gson(); string json = gson.tojson(mylist); 

your json array contains elements like

"{caption=blah, url=/storage/emulated/0/dcim/camera/20140331_164648.jpg}" 

which string not json object. can't therefore try retrieve jsonobject.

seems you're getting json isn't in format expected. if got rid of "" around it, still wouldn't valid json, don't understand purpose enough you.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -