Java Jackson – Json data binding filters

Also see json simple org.json

Jackson provides an effective an efficient way to bind json to POJOs. However, at times, certain properties may need to be ignored while converting a json to java ojbect and a java object to json string. Jackson provides three ways to filter properties.

  1. @JsonIgnoreProperties– This annotation can be used at the type level to ignore json properties. In the example below we ignore the ‘tags’ property from the albums dataset.
  2. @JsonIgnore – This annotation can be set at property level to ignore certain properties.
  3. Using Custom filters

The example below shows method 1 and 2. Also note the use of the @JsonAutoDetect annotation.

Data Binding Filters Example

Databinding

The AlbumsFilter class

DatasetFilter class

2 thoughts on “Java Jackson – Json data binding filters

Leave a Reply

Your email address will not be published. Required fields are marked *