I have the following json:
[
{
"dog":{
"noise":"bark",
"dogfood":"something"
}
},
{
"cat":{
"noise":"meow",
"catfood":"iams"
}
}
]
and the following models:
public abstract class Animal {
}
public class Dog {
private String noise;
private String dogFood;
}
public class Cat {
private String noise;
private String catFood;
}
How do I deserialize each item in the json array with inheritance based on whether the root name for each element is dog or cat?