Trouble Parsing JSON Response in Android -
i having little trouble parsing json response , hoping help..
json string - null{"errormessage":"","issuccess":true,"returnvalue":2}
code example
private static string parseuserresponse(string jsonresponse) { string toreturn =null; system.out.println(jsonresponse); try { jsonobject jsonobj = new jsonobject().getjsonobject(jsonresponse); system.out.println(jsonobj.getstring("issuccess")); system.out.println(jsonobj.getstring("returnvalue")); } catch (exception e) { // todo: email exception e.printstacktrace(); } return (null); }
i have verifed data getting method, blows , throws following exception
09:06.826: info/system.out(526): null{"errormessage":"","issuccess":true,"returnvalue":2} 05-20 00:09:06.836: warn/system.err(526): org.json.jsonexception: no value null{"errormessage":"","issuccess":true,"returnvalue":2} 05-20 00:09:06.856: warn/system.err(526): @ org.json.jsonobject.get(jsonobject.java:354) 05-20 00:09:06.866: warn/system.err(526): @ org.json.jsonobject.getjsonobject(jsonobject.java:569) 05-20 00:09:06.866: warn/system.err(526): @ com.company.program.class.parseuserresponse(myclass.java:84) 05-20 00:09:06.876: warn/system.err(526): @ com.company.program.class.isrealuser(myclass.java:57)
i working android 4.0 sdk if makes diffrence.. advice appreciated.
it should jsonobject jsonobj = new jsonobject(jsonresponse);
, withuot null @ start of string
Comments
Post a Comment