String jsonString = " *{"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"}}
* " ;
The json data which u r getting is a String . what i am thinking the data
which u have give above i man what u want to parse is one object or one
record so in a similar manner u may be having many record so the
jsonstring consists of many objects of same type . now u ll pass this to
the jsonarray and each record is stored in the array and u can fetch one at
a time and do parsing in a for loop.
On Wed, Apr 4, 2012 at 5:01 PM, Mini agrawal <[email protected]> wrote:
> Thanks for reply, still i am getting an parsing error.
> What will be jsonString here?(for a given data)
>
>
> On Tue, Apr 3, 2012 at 10:04 AM, atul gangwar <[email protected]> wrote:
>
>> 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
>
>
> --
> 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