I have bunch of model classes which have fields of type List
where X
is one of many things (e.g. String
, Integer
You can simply write your own JsonDeserializer where you check whether your bleh
or foo
are JsonObjects or JsonArrays.
To check if a JsonElement is an array or an object:
JsonElement element = ...;
if (element.isJsonObject()) {
//element is a JsonObject
} else if (element.isJsonArray()) {
//element is a JsonArray
}