{
"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"
}
Asked
Active
Viewed 71 times
-1

Rajesh Pandya
- 1,540
- 4
- 18
- 31

Mohamed Osama
- 23
- 3
-
If you want to parse to a java class you can youse gson or something similar. – Brank Victoria Jul 19 '18 at 10:12
-
Invalid json, make it in correct json format – Ranjan Jul 19 '18 at 10:13
-
Invalid Json, Kindly post your valid json... beofre posting your json text, check it first on this website https://jsonformatter.curiousconcept.com/ – Shahzad Afridi Jul 19 '18 at 10:16
-
You can parse it manually with https://developer.android.com/reference/org/json/JSONObject or use gson. – Veselin Todorov Jul 19 '18 at 10:19
-
2Possible duplicate of [Parsing values from a JSON file?](https://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file) – hasan_shaikh Jul 19 '18 at 10:22
-
you are missing `]}` at the end of your json – Manohar Jul 19 '18 at 10:42
2 Answers
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

Jala Sureshreddy
- 51
- 7