public void parse() { try { // parsing all images and populating imageData object for (int i = 0; i < images.length(); i++) { JSONObject jsonObject = images.getJSONObject(i); String imageUrlThumbnail = jsonObject.getJSONObject(TAG_IMAGES).getJSONObject(TAG_THUMBNAIL).getString(TAG_URL); if (imageData.isInCache(imageUrlThumbnail)) continue; String imageUrlStdRes = jsonObject .getJSONObject(TAG_IMAGES) .getJSONObject(TAG_STD_RESOLUTION) .getString(TAG_URL); String caption = jsonObject.getJSONObject(TAG_CAPTION).getString(TAG_TEXT); JSONObject user = jsonObject.getJSONObject(TAG_USER); String username = user.getString(TAG_USERNAME); String full_name = user.getString(TAG_FULL_NAME); // tmp hashmap for single image ConcurrentHashMap<String, String> image = new ConcurrentHashMap<>(); // adding each child node to HashMap image.put(TAG_USERNAME, username); image.put(TAG_FULL_NAME, full_name); image.put(TAG_CAPTION, caption); image.put(TAG_LINK_THUMB, imageUrlThumbnail); image.put(TAG_LINK_STD_RES, imageUrlStdRes); imageData.addImageData(image); } } catch (JSONException e) { e.printStackTrace(); } }