0
votes

This is a JSON code which I took from a website. The problem is this code has not square bracket and h0 to h11 have not valid value in an array so I don't know how to use this in my android application.

{"h0":{"id":1081,"imgtitle":{"ar_AA":"","fa_IR":"\u0644\u062d\u0638\u0647 \u0631\u0633\u06cc\u062f\u0646 ...","en_GB":""},"imgtext":{"ar_AA":"","fa_IR":"","en_GB":""},"imgthumbname":"___20141222_1063155393.jpg","params":{"videolink":"","video_format":"","videoPlayingTime":"","position":"","time":"0:0:0"},"catpath":"_9","isvideo":false,"url":"www.EXAMPLE.com/images/joomgallery/thumbnails/_9/___20141222_1063155393.jpg"},

"h1":{"id":1076,"imgtitle":{"ar_AA":"\u0637\u0631\u064a\u0642 \u0646\u062c\u0641 \u0643\u0631\u0628\u0644\u0627\u0621","fa_IR":"\u062f\u0631 \u0631\u0627\u0647 \u0646\u062c\u0641 \u0643\u0631\u0628\u0644\u0627\u0621","en_GB":""},"imgtext":{"ar_AA":"","fa_IR":"","en_GB":""},"imgthumbname":"___20141219_1797008844.jpg","params":{"videolink":"","video_format":"","videoPlayingTime":"","position":"","time":"0:0:0"},"catpath":"_9","isvideo":false,"url":"www.EXAMPLE.com/images/joomgallery/thumbnails/_9/___20141219_1797008844.jpg"},

. .

"h11":{"id":623,"imgtitle":{"ar_AA":"","fa_IR":"\u0639\u0642\u0644 \u062d\u064a\u0631\u0627\u0646..... \u0637\u0628\u0639 \u0633\u0631\u06af\u0631\u062f\u0627\u0646.... \u0632\u0628\u0627\u0646 \u0644\u0627\u0644 \u0627\u0633\u062a\u060c \u0644\u0627\u0644.....","en_GB":""},"imgtext":{"ar_AA":"","fa_IR":"\u0646\u0634\u0633\u062a\u0646 \u0645\u0631\u064a\u0636\u064a \u062f\u0631 \u062c\u0644\u0648\u064a \u062f\u0631\u0628 \u062e\u0627\u0646\u0647\u200c\u0627\u0634 \u062f\u0631 \u0648\u0631\u0648\u062f\u064a \u0634\u0647\u0631 \u0643\u0631\u0628\u0644\u0627 \u0648 \u063a\u0631\u0642 \u0634\u062f\u0646 \u0648\u064a \u062f\u0631 \u0627\u064a\u0646 \u062d\u0627\u062f\u062b\u0647 \u0648 \u0633\u064a\u0644 \u0639\u0638\u064a\u0645 \u0632\u0648\u0627\u0631....\n\u0645\u062a\u0646 :\u0645\u062d\u0645\u062f \u0646\u0627\u0635\u0631 \u0644\u0628\u0627\u0646\u06cc / \u0632\u0647\u0631\u0627 \u067e\u0627\u0631\u0633\u0627 \u067e\u0648\u0631","en_GB":""},"imgthumbname":"________20141201_1727515644.jpg","params":{"videolink":"","video_format":"","videoPlayingTime":"","position":"","time":"0:0:0"},"catpath":"_9","isvideo":false,"url":"www.EXAMPLE.com/images/joomgallery/thumbnails/_9/________20141201_1727515644.jpg"}

}

1
Why do you need it as an array; if its an object then use it as an object. Also, what do you mean by it doesn't have valid value? - Rohit5k2
things you posted are not valid json strings - Pavel Dudka
@PavelDudka thank you I was going to find out if it is valid or not. - hamidreza haajhoseini
@PavelDudka - It appears to be an excerpt from longer JSON data (note the ".." in the middle). - Ted Hopp
I feel ".." simply represents that there are more nodes in between. node name starting with h0 and ending with h11 - Rohit5k2

1 Answers

0
votes

You can use JSONArray and JSONObject to represent arrays and object. Your root element seems to be an object, so you'd like to use JSONObject json = new JSONObject(jsonString);, with this you can call json.getString(String key);, json.getInt(String key);,... to fetch child, and call getJsonObject and getJsonArray(String name); to get child Arrays/Objects