I am parsing JSON data from this link:
http://twyst.in/api/v1/near/30/30
As the data is too large, I am posting only the (problem) relevant data here:
{ "info": "[{\"outlet\":{\"__v\":1,\"_id\":\"5316d59326b019ee59000026\",\"photos\":[],\"twyst_meta\":{\"recommend_list\":[],\"reviews\":[]},\"outlet_meta\":{\"links\":[],\"status\":\"active\",\"accounts\":[\"531574eeae738d654c00000a\",\"535a1a1e827651ca03000122\"]},\"attributes\":{\"dine_in\":true,\"outdoor\":true,\"air_conditioning\":\"Not Available\",\"parking\":\"Available\",\"reservation\":\"Not Required\",\"wifi\":\"Not Available\",\"tags\":[\"Pizza\",\"Pasta\",\"Italian\",\"Galleria\",\"DLF Phase 4\"],\"payment_options\":[\"cash\",\"amex\",\"visa\",\"master\"],\"cuisines\":[\"Italian\",\"Pizza\",\"Gelato\"],\"timings\":\"11 AM - 11 PM\",\"cost_for_two\":{\"min\":3,\"max\":4}},\"links\":{\"other_urls\":[],\"youtube_url\":\"\",\"twitter_url\":\"\",\"facebook_url\":\"https://www.facebook.com/pages/Crusty-gourmet-pizza-more/390843954384130\",\"website_url\":\"\"},\"contact\":{\"emails\":{\"email\":\"[email protected]\",\"person\":\"\"},\"phones\":{\"number\":\"\",\"landline\":\"02355156616\",\"reg_mobile\":[{\"_id\":\"4639320000e4532779b17de7\",\"num\":\"9134000410\"}
This is not the end of JSON data, it goes on...
But when the following line of code is executed, I am getting a JSONException. The e.printStackTrace() method tells me that there is typeMismatch error.
JSONObject object = new JSONObject(str); //1
JSONArray array = object.getJSONArray("info"); //2
I have tried replacing the line 2 with the following code:
JSONObject newObject = object.getJSONObject("info");
But here also I encountered the same problem.
I have checked the complete data, it is correct, no syntax error. Can anybody help me with the issue ? Can the presence of double quotes before starting of JSONArray be the root of this problem ?
Thanks.