Setup: - Android - Retrofit 2 - Gson
My Server json looks like this:
{
"myList1":
{
"1": (<- variable number)
{
"id":"1","name":"user123"
},
"2"{},...},
"myList2":
{
"299": (<- variable number)
{
"id":"20","name":"user42"
},
"300":
{},...}
}
The first node: "myList1" and "myList2" is fix.
Then the second node contains a variable number
And the second node holdes an user object.
-> How do I define the response for the second list with gson?
-> The number and the count of the entries is variable
My Response Mapping looks like:
public class ResponeDef {
@Gson.Named("myList1")
ResponeListDef list1;
@Gson.Named("myList2")
ResponeListDef list1;
}
public class ResponeListDef {
@Gson.Named("??")
ResponeListEntryDef entry1
@Gson.Named("??")
ResponeListEntryDef entry2;
}
public class ResponeListEntryDef {
@Gson.Named("id")
int id;
@Gson.Named("name")
String userName;
}