How do I use custom deserialization on gson for generic type?

Issue For standard POJO, we can use the following GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapter(MyType2.class, new MyTypeAdapter()); gson.registerTypeAdapter(MyType.class, new MySerializer()); gson.registerTypeAdapter(MyType.class, new MyDeserializer()); gson.registerTypeAdapter(MyType.class, new MyInstanceCreator()); How about if the POJO is generic? The Gson user guide doesn’t mention it.

Continue reading