I'm trying to work out how to deserialise a JSON response that can be made up of single or multiple models, so for instance, I have the following URL and Response from that endpoint:
https://api.site.com/products?query=fruit
Which would return something such as this:
{
"fruit": [{ ... },{ ... }]
}
"Fruit" could be anything, but as an alternative, you can also do this:
https://api.site.com/products?query=fruit,pies
{
"fruit": [{ ... }, { ... }],
"pies": [{ ... }, { ... }]
}
So I know how to handle just one of the "selections" provided at a time, however how do I go about deserialising the response when there can be 2 separate models in the same response?