To me, it appears that the incoming JSON does not match what you
expect. In some cases it is a "string" while others it is a Json
Object. Ideally, the incoming JSON would be consistent so it would be
better if "c":null was passed in instead.
If you are unable to change the incoming JSON then unfortunately you
will have to write a custom deserializer for it.
public class SubDataJsonSerializer implements
JsonDeserializer<SubData> {
public T deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context)
throws JsonParseException {
if (json.isJsonPrimitive()) {
// You can add additional check in here to make sure it's an
empty string
return null;
} else {
JsonObject jsonObj = json.getAsJsonObject();
return new SubData(jsonObj.getProperty("d"),
jsonObj.getProperty("e"));
}
}
}
On Mar 30, 2:46 am, Francisco Javier Martínez