Hi,
For parsing json data:
pass the json sting to JSONArray as below.
JSONArray jsonArray = new JSONArray(jsonString);
create JSONObject ;
JSONObject json_data = null;
run one loop as below to fetch each element of the array.
for (int i = 0; i < jsonArray.length(); i++) {
json_data = jsonArray.getJSONObject(i);
string strId = json_data.getString(id);// pass the key here to get
the value
}
if u hav only one object inside the jsonstring thn u can use
json_data.get(type of data present)(pass the key here);
eg to fetch the url
String url= json_data.getstring("url");
//url = *http:\/\/www.zomato.com
\/ncr\/restaurants\/south-delhi\/mathura-road\/sagar-ratna-315*
On Thu, Mar 29, 2012 at 12:50 PM, Mini agrawal <[email protected]> wrote:
> How to parse following data??
>
>
> " *{"id":315,"name":"Sagar
> Ratna","url":"http:\/\/www.zomato.com\/ncr\/restaurants\/south-delhi\/mathura-road\/sagar-ratna-315","location":{"address":"B-1,
> A-11 Mohan Co-operative Ind Area, Mathura Road, New
> Delhi","locality":"Mathura
> Road","city":"Delhi","latitude":"28.5207270000","longitude":"77.2942530000"},"phone":"011
> 26955802, 011 26955803, 011 26955804","cuisines":"South
> Indian","timings":"11 AM to 11
> PM","avgCostForTwo":450,"isPureVeg":1,"hasBar":0,"hasDineIn":1,"hasDelivery":1,"acceptsCreditCards":1,"serviceCharge":0,"vat":1,"editorRating":{"food":2.5,"service":3.5,"ambience":2,"overall":3},"editorReview":"","userReviews":{"count":2,"0":{"review":{"id":"24728","rating":0,"reviewText":"yyejbbxzszbxzbomato.comForDevelopmentPurposes","author":"Arup
> Saha","reviewTime":"2012-01-25 16:23:10","reviewTimeFriendly":"2 months
> ago"}},"1":{"review":{"id":"24727","rating":5,"reviewText":"testReviewOnZomato.comForDevelopmentPurposes","author":"Arup
> Saha","reviewTime":"2012-01-25 16:14:16","reviewTimeFriendly":"2 months
> ago"}}},"discounts":[],"photos":{"photos_url":"http:\/\/www.zomato.com
> \/ncr\/restaurants\/south-delhi\/mathura-road\/sagar-ratna-315\/photos#tabtop","0":{"photo":{"thumbUrl":"http:\/\/
> www.zomato.com\/data\/pictures\/chains\/305\/1_thumb.jpg","url":"http:\/\/
> www.zomato.com
> \/data\/pictures\/chains\/305\/1.jpg"}}},"image_470_310":"","image_310_310":"","image_310_150":"","image_150_150":"","menu":{"menu_url":"http:\/\/
> www.zomato.com
> \/ncr\/restaurants\/south-delhi\/mathura-road\/sagar-ratna-315\/menu#tabtop"}}
> * "
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en