[
{
"vendor_name": "Chef Neha Jain",
"vendor_avatar": "http://www.avatarsdb.com/avatars/dear_god.jpg",
"vendor_type": "indivisual",
"vendor_rating": "0",
"vendor_phone": "9875463210",
"vendor_address": "Golf Course Road Sector 54 New Vatika Towers Gurgaon",
"vendor_neighbourhood": "Sector 54",
"vendor_city": "gurgaon",
"dish_id": "2",
"dish_name": "Dal Baati Churma Thali",
"dish_image": "http://s3-ap-southeast-1.amazonaws.com/elasticbeanstalk-ap-southeast-1-779583297639/Dish%2FImages%2FDal+Baati+Churma+Thali%2FNormal%2Fdal_baati_churma_thali-hdpi.jpg",
"dish_description": "{\"main\":\"Dine in on a grand feast of authentic cuisine from Rajasthan. Panchmel Dal, Baati, Churma, Tadka Kadhi, Lehsun Chutney, Jeera Rice all come together to create a culinary memory that you would have seldom experience before.\",\"other\":\"Served as Panchmel Dal, 2 Baatis, Churma, Tadka Kadhi, Lehsun Chutney and Jeera Rice\"}",
"dish_palate": "[\"2\",\"4\"]",
"dish_tags": "Baati,Daal",
"dish_cost": "200",
"dish_price": "250",
"dish_rating": "4.5",
"$$hashKey": "object:7"
}
]
Asked
Active
Viewed 64 times
-2

Andrey Korneyev
- 26,353
- 15
- 70
- 71

Sourav Mandal
- 13
- 4
-
Man you should at least search? If you are new to android development then learn [JSON Parsing](http://www.technotalkative.com/android-json-parsing/) – Paresh Mayani May 22 '15 at 10:36
-
And there are many questions/answers already exists on Stackoverflow! – Paresh Mayani May 22 '15 at 10:37
-
Yes i did search,but i am confused on accessing the main tag inside dish description since the parenthesis is inside the quotes.Can anybody help me here? – Sourav Mandal May 22 '15 at 10:42
-
If you don't want to manually parse and if your JSON is fixed then use `GSON` library! With that you just need to define the POJO class! – Paresh Mayani May 22 '15 at 10:46
1 Answers
1
Refer below way to parse json response, If you are getting response in string otherwise remove JSONArray array = new JSONArray("res") line if getting json array.
try {
JSONArray array = new JSONArray("res");
for (int i = 0; i < array.length(); i++) {
JSONObject jsonObject = array.getJSONObject(i);
String vendor_name = jsonObject.getString("vendor_name");// same way parse all string
if(jsonObject.has("dish_description")){
String dish = jsonObject.getString("dish_description");
dish = dish.replaceAll("[\\W]", "");
JSONObject jsonObject2 = new JSONObject(dish);
String main = jsonObject2.getString("main");// same way get other one
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Anjali Tripathi
- 1,477
- 9
- 28
-
how do i access the main tag of dish description?since the parenthesis is inside quotes – Sourav Mandal May 22 '15 at 10:40
-
You can get it into String as I mentioned and now its up to you how to use that string. – Anjali Tripathi May 22 '15 at 10:42
-
Is there any other way other than string editing?,coz i am looking for nested multilevel tags,but i cannot use them due to nesting parenthesis of "dish_description" being included inside its string field!! – Sourav Mandal May 22 '15 at 10:58
-
you can do editing with your string but it is necessary to get it into string – Anjali Tripathi May 22 '15 at 11:02
-
-
My requirement is to know and point all the field tags of dish_description,since the number of fields in it are dynamic.Anyways,thanks for the help..:) – Sourav Mandal May 22 '15 at 11:09
-
you can do one take it into string then convert it into jsonObject – Anjali Tripathi May 22 '15 at 11:12
-
-
-