ip-jackson-databind
Provides support for serializing and deserializing IP addresses and ranges using Jackson. All you need to do is register a module. This can be done in two ways:
-
Using
ObjectMapper.registerModule
:mapper.registerModule(IPModule.instance());
-
Using
ObjectMapper.findAndRegisterModules()
. This will register not just an instance ofIPModule
, but any other module that's made available through the Service Provider Interface (SPI) mechanism:mapper.findAndRegisterModules();
No matter which way you choose, it will automatically allow all instances of IPAddress, IPRange and Subnet to be serialized and deserialized, without the need for any custom serializer or deserializer.