Thursday, 15 July 2010

android - getstring() giving null value in jsonparsing -



android - getstring() giving null value in jsonparsing -

i getting next response server

{"response":"attendance","status":"success","projid":1,"invalid_labours":[]}.

i wrote next code of parsing

jsonobject jsonobj = new jsonobject(attendanceresponse); string response = jsonobj.getstring("response); string status = jsonobj.getstring("status); string projectid = jsonobj.getstring("projid"); jsonarray invalidlaborid = jsonobj.getjsonarray("invalid_labours");

but giving nullpointer while fetching projid field

replace

string projectid = jsonobj.getstring("projid");

with

int projectid = jsonobj.getint("projid");

also seems missing double quote...

-------------------------------------------------------------------------\/

string response = jsonobj.getstring("response");

android json

No comments:

Post a Comment