I want to receive items using retrofit and parse them into a Java list. However, the server response is not a JSON array but a JSON object containing the items. That is why retrofit cannot just convert the response into a java list.
The response looks something like this:
{
"4": {
"key": "value",
...
},
"5": {
...
},
...
}
Usually, I would try to receive the items like this:
@GET("items")
Call<List<Item>> getItems();
But this obviously does not work and Retrofit responds: Expected BEGIN_ARRAY but was BEGIN_OBJECT
What is my best option to convert this object into a java list using retrofit?
>>. Try a bit arround, good luck.
– Daniel Spiess Aug 16 '19 at 14:45