How to Pass JSON Array using JSON Object How to Pass JSON Array using JSON Object json json

How to Pass JSON Array using JSON Object


Your itemArrayList is global and on parsing you're adding items to that list each time you read a category. For that reason your itemListArray include all items. Since it is reference to a list when you add an item to list, you're also adding item to previous categories since they reference to same list. Try changing your inner loop like this.

ArrayList<Items> itemsArrayList = new ArrayList<Items>();    for(int j=0; j<imagesArray.length(); j++)                        {                        JSONObject imagesObject = imagesArray.getJSONObject(j);                    items = new Items();                    items.setTitle(imagesObject.getString("title"));                    items.setImage(imagesObject.getString("image"));                                                    itemsArrayList.add(items);                }