Skip to content
Advertisement

Abstract class with Gson serialization/deserialization

I am expecting to get from a json a LinkedList<Request>. The pojos look like this:

JavaScript

The serialization works fine, it generates the json, but it crashes at deserialization (maybe it’s the abstract class or/and that I am expecting a LinkedList and/or the lombok annotations)? I tryed writting a gson deserializer (quite a standard one found googling), but it doesn’t do the job.

Advertisement

Answer

Thanks to @fluffy’s suggestion, I managed to skip writing a custom deserialiser and making use of RuntimeTypeAdapterFactory from gson-extras library:

JavaScript

I also kept only the lombok annotations and did not write constructors and getters/setters for my POJOs

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement