@Nullable protected Comparable deserializeComparable(@Nullable JsonElement comparableJson, JsonDeserializationContext jsonDeserializationContext) { if (comparableJson == null) { return null; } JsonArray jsonArray = comparableJson.getAsJsonArray(); // the classname is serialized as the first element, the value is serialized as the second Class<? extends Comparable> comparableClass = forName(jsonArray.get(0).getAsString()); return jsonDeserializationContext.deserialize(jsonArray.get(1), comparableClass); }