How to invoke default deserialize with gson

Try using GSON >= 2.2.1 and look for the TypeAdapterFactory class.

This will give you the ability to inspect the Object before you deserialize it and apply custom code while avoiding recursions.

Here is an example of the getDelegateAdapter you can use.


public class ExtrasAdapter implements JsonDeserializer<Extras> {
@Override
public Extras deserialize(JsonElement json, Type typeOf, 
              JsonDeserializationContext context) throws JsonParseException {
    try {
        JsonObject jsonObject = json.getAsJsonObject();
        return new Gson().fromJson(jsonObject , Extras.class); // default deserialization

    } catch (IllegalStateException e) {
        return null;
    }
}