JsonArray jArray = new JsonArray(jsonString); for(int i=0;i<jArray.size();i++){ // Here you can get your json object JsonObject jObj = jArray.getJSONObject(i); // use this json object: jObj String id = jObj.getString("id"); }
String json = getIntent().getString("json"); JsonArray jsonArray = new JsonArray(json); try { for (int i = 0; i < jsonArray.length(); ++i) { final JSONObject object = jsonArray.getJSONObject(i); ...
try { JSONObject jsonObj = new JSONObject(jsonStr); // Getting JSON Array node JSONObject jsonpost= jsonObj.getJSONObject("post"); // looping through All Contacts for (int i = 0; i < jsonpost.length(); i++) { JSONObject c = jsonpost.getJSONObject(i); JsonArray comments=c.getJSONArray("comments"); for (int j = 0; j< comments.size();j++) { JSONObject jj = comments.getJSONObject(j); String id = jj.getString(TAG_ID); String name = jj.getString(TAG_NAME); String content = jj.getString(TAG_CONTENT); // tmp hashmap for single contact HashMap<String, String> contact = new HashMap<String, String>(); // adding each child node to HashMap key => value contact.put(TAG_ID, id); contact.put(TAG_NAME, name); contact.put(TAG_CONTENT, content); // adding contact to contact list queryList.add(contact); } }
JSONObject e = arr.getJSONObject(i);