I'm trying to show images array in a list but I didn't figured it out yet, can anyone please help me.
This may seem as a repeated question, but I tried other answers, they didn't work.
My JSON:
[
{
"id": 52,
"name": "viber",
"images": [
"7829-hit-the-vibe.gif",
"8413_Lit.gif",
"8095_Lazergunzoncam.gif",
"7090_LaserCamz.gif",
"2123-vibe-4.gif",
"3175-vibe-3.gif",
"7413-vibe-2.gif",
"1100-vibe.gif",
"6381-lazeroncamz-2.gif"
],
"download": null,
"amount": 9
},
{
"id": 45,
"name": "aesthetic",
"description": "a",
"slug": "6039-aesthetic",
"images": [
"4071_planet.png",
"3499_love_it.png",
"3019_space_bottle.png",
"6033_pixel_flower.png",
"1620-cupcake-pink.gif",
"2760-seashell-pink.gif",
"1794_sparkles.gif",
"2523_RamSip.png"
],
"download": null,
"amount": 8
},
]
My code:
String jsonString = "myjson";
json1 = new Gson().fromJson(jsonString, new TypeToken<ArrayList<HashMap<String, Object>>>(){}.getType());
for(int _repeat24 = 0; _repeat24 < (int)(json1.size()); _repeat24++) {
JSONObject obj = new JSONObject(jsonString);
JSONArray getArray = obj.getJSONArray("images");
JSONObject objects = getArray.getJSONObject(_repeat24);
Iterator key = objects.keys();
while (key.hasNext()) {
String value = key.next();
}
}
My task: I'm trying to save the array images as json in a key value, example:
categoriesMap = new HashMap<>();
categoriesMap.put("name", name);
categoriesMap.put("imagesJson", JSON_I_NEED);
json1.add(categoriesMap);
This should work as a loop for all the array positions. Thanks.