In deserialization I am trying to map different JSON nodes to a single field using GSON.
I have the next field in a class:
private List<MyObjects> pages;
Incoming json may be:
{
"pages": [
{
"pageNumber": "1"
}
]
}
Or
{
"pages": {
"list": [
{
"pageNumber": "1"
}
]
}
}
I am trying to map the array of pages to the pages class field using this:
@SerializedName(value = "pages", alternate = "pages.list")
public List<MyObjects> pages;
but it doesnt work.
It seems that GSON does not support this. But maybe someone knows why?