I want to deserialize a JSON string using the same POJO for two king of messages. Take a look at the message below
{
"success": true,
"data": [
{
"id": 2,
"Idea": null
},
{
"id": 3,
"Idea": null
}
]
}
The data is an array, but sometimes the data is a single object:
{
"success": true,
"data":
{
"id": 2,
"Idea": null
}
}
My POJO looks like this:
public void setData(List<Object> data)
{
this.data = data;
}
Is there any way to deserialize the second message (where data is not an array) using the same class?
Kind regards, Ricardo
