Example:
public class HistoryRecordDeserializer implements JsonDeserializer<HistoryRecord> { private LocalDateTimeConverter dateTimeConverter = new LocalDateTimeConverter(); @Override public HistoryRecord deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { User user = new User(); user.setId(UUUID.fromString(json.get("user").get("id").getAsString())); OtherData data = new OtherData(); data.setData(json.get("otherData").getAsLong()); return UserAndData(user, otherData); } I manually deserialize the User and OtherData objects. How can you do better? There is an idea to use an instance of Gson, passing it in the constructor, or create a new one in the HistoryRecordDeserializer . There are other options?