0
{
    "err": false,
    "msg": "SUCCESS",
    "data": {
        "items": [
            {
                "id": "i01",
                "name": "featured"
            },
            {
                "id": "i07",
                "name": "continueWatching"
            },
            {
                "id": "i03",
                "name": "recommended"
            },
            {
                "id": "i04",
                "name": "trailers"
            },
            {
                "id": "i05",
                "name": "latestSeries"
            },
            {
                "id": "i06",
                "name": "allSeries"
            },
            {
                "id": "i08",
                "name": "malayalam"
            },
            {
                "id": "i09",
                "name": "tamil"
            },
            {
                "id": "i10",
                "name": "hindi"
            },
            {
                "id": "i11",
                "name": "telugu"
            },
            {
                "id": "i12",
                "name": "kannada"
            }
        ],
        "featured": {
            "id": 15,
            "name": "Wizards:Tales of Arcadia",
            "description": "Wizards:Tales of Arcadia Animated Series",
            "poster": "series/15/poster/1674561938132-wtoa.jpg",
            "active": true,
            "created_at": "2023-01-18T09:24:27.732Z",
            "updated_at": "2023-01-18T09:24:27.732Z",
            "featured": true,
            "director": "",
            "casts": [
                {
                    "name": "cast1"
                },
                {
                    "name": "cast2"
                }
            ],
            "genres": [
                {
                    "id": 1,
                    "name": "Action"
                },
                {
                    "id": 13,
                    "name": "Fantasy"
                }
            ],
            "seasons": [
                {
                    "id": 10,
                    "series_id": 15,
                    "name": "Season 1",
                    "description": "Season 1 of Wizards:Tales of Arcadia",
                    "episodes": [
                        {
                            "id": 20,
                            "fwp_id": "d29433a2-1724-4a6c-a1ba-a6973920b2f3",
                            "series_id": 15,
                            "season_id": 10,
                            "name": "WTOA S1 E1",
                            "description": "Wizards:Tales of Arcadia Season 1 Episode 2",
                            "poster": "videos/d29433a2-1724-4a6c-a1ba-a6973920b2f3/poster/1674563591831-wtoa.jpg"
                        },
                        {
                            "id": 20,
                            "fwp_id": "d29433a2-1724-4a6c-a1ba-a6973920b2f3",
                            "series_id": 15,
                            "season_id": 10,
                            "name": "WTOA S1 E1",
                            "description": "Wizards:Tales of Arcadia Season 1 Episode 2",
                            "poster": "videos/d29433a2-1724-4a6c-a1ba-a6973920b2f3/poster/1674563591831-wtoa.jpg"
                        },
                        {
                            "id": 21,
                            "fwp_id": "43eb2eab-bb2d-43f0-aa2d-3d4ab18489c0",
                            "series_id": 15,
                            "season_id": 10,
                            "name": "WTOA S1 E2",
                            "description": "Wizards:Tales of Arcadia Season 1 Episode 2",
                            "poster": "videos/43eb2eab-bb2d-43f0-aa2d-3d4ab18489c0/poster/1674563538467-wtoa.jpg"
                        },
                        {
                            "id": 21,
                            "fwp_id": "43eb2eab-bb2d-43f0-aa2d-3d4ab18489c0",
                            "series_id": 15,
                            "season_id": 10,
                            "name": "WTOA S1 E2",
                            "description": "Wizards:Tales of Arcadia Season 1 Episode 2",
                            "poster": "videos/43eb2eab-bb2d-43f0-aa2d-3d4ab18489c0/poster/1674563538467-wtoa.jpg"
                        }
                    ]
                }
            ],
            "itemId": "i01"
        },
        "continueWatching": [
            {
                "itemId": "i07",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        ],
        "recommended": [
           
            {
                "itemId": "i03",
                "id": 10,
                "name": "Castlevania",
                "description": "Castlevania Animated Series",
                "poster": "series/10/poster/1674562131889-castlevania.jpg",
                "active": true,
                "created_at": "2023-01-18T08:51:18.723Z",
                "updated_at": "2023-01-18T08:51:18.723Z",
                "season_count": 2,
                "episode_count": 6,
                "genres": [
                    {
                        "id": 13,
                        "name": "Fantasy"
                    },
                    {
                        "id": 1,
                        "name": "Action"
                    }
                ]
            }
        ],
        "trailers": [
            {
                "itemId": "i04",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        ],
        "allSeries": [
            {
                "itemId": "i06",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        ],
        "malayalam": [
            {
                "itemId": "i08",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        "tamil": [
            {
                "itemId": "i09",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        ],
        "hindi": [
            {
                "itemId": "i10",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        ],
        "telugu": [
            {
                "itemId": "i11",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        ],
        "kannada": [
            {
                "itemId": "i12",
                "id": 15,
                "name": "Wizards:Tales of Arcadia",
                "description": "Wizards:Tales of Arcadia Animated Series",
                "poster": "series/15/poster/1674561938132-wtoa.jpg",
                "active": true,
                "created_at": "2023-01-18T09:24:27.732Z",
                "updated_at": "2023-01-18T09:24:27.732Z",
                "season_count": 1,
                "episode_count": 2,
                "genres": [
                    {
                        "id": 1,
                        "name": "Action"
                    },
                    {
                        "id": 13,
                        "name": "Fantasy"
                    }
                ]
            }
        ]
    },
    "details": []
}

I am trying to display multiple arraylists from a JSON object in a nested RecyclerView using Android kotlin. I have been able to successfully parse the JSON object and extract the arraylists, but I am having trouble displaying them in the nested RecyclerView.

Here is an example of the JSON object I am working with

Zoe
  • 27,060
  • 21
  • 118
  • 148
swaroop
  • 294
  • 1
  • 2
  • 13

1 Answers1

0

For example my simple JSON multiple Arraylist

{
"page":1,
"per_page":3,
"total":12,
"total_pages":4,
"data": [
    {
        "id": 1,
        "name": "akila",
        "year": 2000,
        "pantone_value": "15-4020"
    },
    {
        "id": 2,
        "name": "prasanth",
        "year": 2001,
        "pantone_value": "17-2031"
    },
    {
        "id": 3,
        "name": "santhiya",
        "year": 2002,
        "pantone_value": "19-1664"
    }
]

}

you must declare multiple arraylists in your model class

For example MultipleResource model class - JAVA

public class MultipleResource {

@SerializedName("page")
public Integer page;
@SerializedName("per_page")
public Integer perPage;
@SerializedName("total")
public Integer total;
@SerializedName("total_pages")
public Integer totalPages;
@SerializedName("data")
public List<Datum> data = null;

public class Datum {

    @SerializedName("id")
    public Integer id;
    @SerializedName("name")
    public String name;
    @SerializedName("year")
    public Integer year;
    @SerializedName("pantone_value")
    public String pantoneValue;

}
}

handle multiple json arraylist - example code (JAVA)

   Call<MultipleResource> call = apiInterface.doGetListResources();
    call.enqueue(new Callback<MultipleResource>() {
        @Override
        public void onResponse(Call<MultipleResource> call, Response<MultipleResource> response) {
            Log.d("TAG", response.code()+"");
            String displayResponse = "";

            MultipleResource resource = response.body();
            Integer text = resource.page;
            Integer total = resource.total;
            Integer totalPages = resource.totalPages;
            List<MultipleResource.Datum> datumList = resource.data;

            displayResponse += "Page :" + text + "\n" + "Total :" + total + "\n" + "Total Pages :" + totalPages;

            for (MultipleResource.Datum datum : datumList){
                displayResponse += "\n" + datum.id + "" + datum.name + datum.pantoneValue + datum.year ;
            }
            responseText.setText(displayResponse);
        }

        @Override
        public void onFailure(Call<MultipleResource> call, Throwable t) {

        }
    });

output

Prasanth John
  • 146
  • 1
  • 4