I need to deserialize some JSON to Java class. I have the following JSON:
{
"list": [[{
"type": "text",
"subType": "ss"
},
{
"type": "image",
"subType": "text"
}
]]
}
and I have the following Java classes:
public abstract class BaseClass {
public String type;
public String subType;
}
public class Text extends BaseClass {
...
}
public class Image extends BaseClass {
}
and I need deserialize in this way, if type
equals image
and subType
equals text
I need to deserialize into Text
class otherwise I need deserialize to Image
class.
How can I do it?