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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -