I’m working with an API that sometimes contains a list of child objects:
{ 'obj' : { children: [ {id: "1"}, {id: "2"} ] } }
I can parse this no problem. But if there just one child it doesn’t return it as a list:
{ 'obj' : { children: {id: "1"} } }
My parser which expects a list then breaks. Does anyone have a suggestion for how to deal with this?
With Gson, the only way I know how to handle situations like this is with a custom Deserializer. For example: