Actually, the question is, is it more efficient to use custom Gson serializers / deserializers for each POJO or is it easier to use the automatic serialization available in Gson (of course, in cases where special serialization is not required)?

The same question applies to Jackson (he did not work with him, but as far as I understood, a similar question arises there too).

    1 answer 1

    Here you decide. But using ready-made solutions ( gson , jackson , etc.) you get:

    1. Ready solution out of the box. Saves development time
    2. Sophisticated interfaces that allow the use of both existing and samopisnyh variants of the serialization / deserialization solution for "not ordinary" cases
    3. A lot of literature and forums where, in which case, you can find a solution to the problem.

    The use of your "custom" classes will already depend on how you implement them.
    Most likely, of course, they will be a little less effective (because as if you didn’t have to do jumps with realization, you wouldn’t bother).
    But in fact, if you do everything correctly, you will not feel the difference.

    PS: in the course of our work, we often use for converting, for example, date formats, data transliteration for the end user. There were no problems. If performance measurements were different, then in milliseconds or even less

    • You did not quite understand me correctly (and I did not quite correctly put it, now I’ll edit it). I mean, a comparison of using custom GSON - serializers and automatic GSON - serializers. - Janislav Kornev
    • Here it depends on HOW you write the code yourself) You yourself understand, add an infinite loop to your implementation - and that's that) And if without jokes - then we often use to send, for example, users with a field with a specific date format. Differences are not noticed. Is that the size of the class has become more - Chubatiy
    • @ Janislav Kornev supplemented the answer - Chubatiy