-1
{
  "result_count": 251175,
  "images": [
    {
      "id": "649682800",
      "display_sizes": [
        {
          "is_watermarked": false,
          "name": "thumb",
          "uri": "https://media.gettyimages.com/photos/sergi-roberto-of-barcelona-celebrates-as-he-scores-their-sixth-goal-picture-id649682800?b=1&k=6&m=649682800&s=170x170&h=UjuhQ2k4pOnhCh5a1oLuC4t5rwX8332a-PEqZ8dpUfY="
        }
      ],
      "referral_destinations": [
        {
          "site_name": "gettyimages",
          "uri": "https://www.gettyimages.com/detail/news-photo/sergi-roberto-of-barcelona-celebrates-as-he-scores-their-news-photo/649682800"
        }
      ],
      "title": "FC Barcelona v Paris Saint-Germain - UEFA Champions League Round of 16: Second Leg"
    }
Rajesh Pandya
  • 1,540
  • 4
  • 18
  • 31

2 Answers2

0

The above JSON Data is missing ] } . So make the data a valid JSON by adding ] } at the end

    JSONObject jsonObject = new JSONObject(response);
    JSONArray jsonArray = jsonObject.optJSONArray("images");

    for(int i=0; i< jsonArray.length(); i++)
    {
        JSONObject jsonObjec = jsonArray.optJSONObject(i);
        jsonObjec.optString("id");
        jsonObjec.optString("title");

        JSONArray display_sizes = jsonObjec.optJSONArray("display_sizes");
        // get the display_sizes Array details

        JSONArray referral_destinations = jsonObjec.optJSONArray("referral_destinations");
        // get the referral_destinations Array details
    }
Pradeep Kumar
  • 102
  • 1
  • 7
-1

First it is invalid json. Try using gson library to parse the json.

Try this link gson library to parse json