android - parsing the Json Data -
here posting json response below:
{"resultset": {"result":[ {"phone":"(650) 473-9999", "distance":"2.59", "mapurl":"http://maps.yahoo.com/maps_result?q1=441+emerson+st+palo+alto+cagid1=28734629", "categories": {"category":[ {"content":"salad restaurants", "id":"96926225"}, {"content":"vegetarian restaurants", "id":"96926239"}, {"content":"pizza", "id":"96926243"}, {"content":"wine", "id":"96926864"}, {"content":"alcoholic beverages", "id":"96929810"}]}, "city":"palo alto", "title":"patxi's chicago pizza", "state":"ca", "rating": {"lastreviewdate":"1241373758", "lastreviewintro":"my husband brought me slice of pizza after had heard glowing reviews sarah , vinnie morning show on alice radio (they theirs sf location). anyway had been interested in trying sounded special pizza. husband , son went during time when can buy slices waiting food wasnt issue. dont pizza cold time got home me luke warm. not problem! amazed @ how yummy , having hardest time not eating while standing in kitchen leaning on pizza-to-go box! im not sure of name of slice except did have sausage , possibly spinach in it. week ago , ive been craving ever since. when go either order ahead save on wait or go during pizza slice hours. ive heard ny style of thin crust fans! check out!!", "totalreviews":"27", "totalratings":"27", "averagerating":"4.5"}, "address":"441 emerson st", "latitude":"37.445242", "longitude":"-122.163427"}]}}
noe want have following data parsed "phone", "distance", "city", "title", "state" , "averagerating" tag "rating".
can please in sorting particularly.
thanks, david
i've written subject before here on so, @ here: json parsing in android application
posted code:
string phone = null; string distance = null; string city = null; string title = null; string state = null; string averat = null; jsonobject jsonobject = new jsonobject(yourresponse); jsonarray infoarray = jsonobject.getjsonarray("result"); jsonarray ratingarray = jsonobject.getjsonarray("rating"); (int = 0; < infoarray.length(); i++) { try { phone = infoarray.getjsonobject(i).optstring("phone"); distance = infoarray.getjsonobject(i).optstring("distance"); city = infoarray.getjsonobject(i).optstring("city"); title = infoarray.getjsonobject(i).optstring("title"); state = infoarray.getjsonobject(i).optstring("state"); averat = ratingarray.getjsonobject(i).optstring("averagerating"); } catch (jsonexception e) { } }
Comments
Post a Comment