java - Convert string to JSON array -
i have following string of json web service , trying convert json array
{ "locations": [ { "lat": "23.053", "long": "72.629", "location": "abc", "address": "def", "city": "ahmedabad", "state": "gujrat", "phonenumber": "1234567" }, { "lat": "23.053", "long": "72.629", "location": "abc", "address": "def", "city": "ahmedabad", "state": "gujrat", "phonenumber": "1234567" }, { "lat": "23.053", "long": "72.629", "location": "abc", "address": "def", "city": "ahmedabad", "state": "gujrat", "phonenumber": "1234567" }, { "lat": "23.053", "long": "72.629", "location": "abc", "address": "def", "city": "ahmedabad", "state": "gujrat", "phonenumber": "1234567" }, { "lat": "23.053", "long": "72.629", "location": "abc", "address": "def", "city": "ahmedabad", "state": "gujrat", "phonenumber": "1234567" } ] }
i validated string online, seems correct. using following code in android development utilize
jsonarray jsonarray = new jsonarray(readlocationfeed);
this throw exception typemismatch.
i didn't understood problem newbie android java.
here jsonobject change
jsonarray jsonarray = new jsonarray(readlocationfeed);
line following
jsonobject jsnobject = new jsonobject(readlocationfeed);
and after
jsonarray jsonarray = jsnobject.getjsonarray("locations"); (int = 0; < jsonarray.length(); i++) { jsonobject explrobject = jsonarray.getjsonobject(i); }
Comments
Post a Comment