How to parse json array without json object title in android?
android, http, json
Solution
This is a JSONArray and not a JSONObject - to make a JSONObject from it, use
JSONObject jsonObject = jsonArray.getJSONObject(0);
this gets the first JSONObject from this JSONArray.
If you have multiple JSONObjects, use this:
JSONObject jsonObject;
for(int n = 0; n < jsonArray.length(); n++)
{
jsonObject = jsonArray.getJSONObject(n);
}
To get the values:
jsonObject.getString("name");
Problem
``` [ { "name": "The Universe & The Earth" , "imagename": "cat1.jpg" , "active": "Y" , "createdon": "1901-01-01" , "lastmodifiedon": "1901-01-01 00:00:00" , "description": "Knowledge of Earth location in the universe has been shaped by 400 years of telescopic observations, and has expanded radically in the last century.\n" , "id": "1" } , { "name": "Life on Earth" , "imagename": "cat2.jpg" , "active": "Y" , "createdon": "1901-01-01" , "lastmodifiedon": "1901-01-01 00:00:00" , "description": "Over the last 3.7 billion years or so, living organisms on the Earth have diversified and adapted to almost every environment imaginable." , "id": "2" } ] ``` This is my json values. Now i want to parse and displayed in custom list view how can i do this? I followed http://www.androidhive.info/2012/01/android-json-parsing-tutorial/ this is link but can't be achieve. How can i do this? Can anybody tell me? Thanks in advance.