Jackson is a popular library to handle JSON in Java. It has built-in serializers and deserializers to handle common data types. If you want to serialize and deserialize custom types, you can add custom serializers and deserializers. The code in this post is tested using Jackson 2.7.2 and should work with Jackson after 1.7.
The class we want to serialize and deserialize is
com.github.zafarkhaja.semver.Version from the jsemver library. We want objects of this class to be serialized as simple strings, e.g.