Jackson, one of my favorite tools to use for Java POJO to/from JSON, has a number of configuration settings. Today I am going to discuss a few of these settings and why I recommend the ones that I do.
Serialization is the conversion of Java POJO’s to JSON. These feature control, how that conversion is handled.
If you are passing your JSON over the network, then I recommend setting this value to FALSE. However, if you are not sending your JSON over the network, then I would leave this feature as TRUE.
Disabling this will save you bytes in the data transfer. While the bytes used for the name of the field, may not be many, consider when it’s part of an array, multiple that out. Over time it can be a significant number of bytes that can be saved.
Start with this setting on from the beginning and develop your application with this setting. This will ensure all of your code supports this. Trying to enable this in the middle of development can mean a considerable chunk of time making modifications to support missing fields.
Set this to FALSE to allow dates to be passed as
This is a development decision, and the role your ENUMs are going to play. If the text of your enum is what you need then set this to FALSE. However, if bytes count, set this to TRUE, as an ordinal number will be smaller in bytes than the textual representation.
Deserialization is the conversion of JSON to POJO’s.
Always a good one to set to FALSE. Prevent Jackson from throwing an exception if an additional field is found in the JSON. This way the JSON can be updated and ready to make use of a new field prior to POJO if necessary. This will help encapsulate your work allowing for things to be added in slowly.