Android not parsing JSON Array -
i trying parse json array in code problem never enters try block.
here code:
protected void doinbackground(void... arg0) { jsonparser jsonparser = new jsonparser(); string json = jsonparser.getjsonfromurl("http://hills.ccsf.edu/~jpark41/vib/sample.json"); if(json != null) { log.i("json: ", "not null"); // log executes!! try { log.i("we: ", " out here"); // not!! jsonobject jobj = new jsonobject(json); jsonarray jsar = new jsonarray(json); iterator<string> iter = jobj.keys(); while (iter.hasnext()) { string key = iter.next(); try { jsonobject value = (jsonobject)jobj.get(key); id = value.getstring("id"); thumb = value.getstring("thumb"); media = value.getstring("media"); title = value.getstring("title"); } catch (jsonexception e) { // went wrong! } now_playing = id; earned = title; } } catch (jsonexception e) { log.i("we not: ", " out here"); // todo auto-generated catch block e.printstacktrace(); } } return null; }
"we out here" never logged, "we not out here". why try block never executing? don't have experience parsing json android i'm sure i'm missing something. help.
when commented out jsonobject jobj = new jsonobject(json); , swapped out iterator basic loop worked. everyones help.
Comments
Post a Comment