Hi @damienburke,
I understand that it is not a good approach to have two different sets of objects for serialization and deserialization.
The reason I have written it like that is because of Gson.The thing is, one can’t guarantee the depth of graph, for example friends can again have friends, and so on. And, serialization would work fine with those annotations, but while deserializing, if I use the same POJO as the one which has all annotations, then I can’t use Gson inside the custom deserializer as it will use those annotations which I don’t want to.
So, I have written it with two different sets of POJOs.
But, if you were to use Jackson instead of Gson for json mapping, then you would have the ability to specify different names for serialization and deserialization for the same field, as mentioned in this stack overflow post:
Then, you can have only one POJO, with a custom deserializer using Jackson, while for serialization you could just use Jackson annotations on the same POJO.
I would really recommend you to switch to Jackson, if possible. It is a lot more customisable and offers a lot more features than Gson. Also IIRC, its speed benchmarks were better than Gson in a variety of conditions.
Thanks