In this blog post, we'll extend the journey on writing a custom Gson serializer. In the first part we've shown all basics of setting up the code to customize Gson's JSON serialization. If you haven't read it yet, you might want to do so now, since this blog post is going to build upon it.
The first part had a focus on simplifying JSON objects before sending them to the server. In this second part, we'll look at another reason to customize the serialization: Java objects that have no or an inappropriate default serialization.
Of course, this will not be the only post in our Gson series. If you're interested in the other topics, check out our series outline:
Gson Series Overview
- Mapping of Enums
- Mapping of Circular References
- Custom Serialization for Simplification (Part 1)
- Changing the Default Serialization with Custom Serialization (Part 2)
- Custom Deserialization Basics
- Custom Instance Creator
- Customizing (De)Serialization via @JsonAdapter
- Custom Deserialization for Calculated Fields
- On-The-Fly-Parsing With Streams
- ProGuard Configuration