Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 1.16 KB

File metadata and controls

15 lines (12 loc) · 1.16 KB

conditional-jackson-property-filter

An extension of the Jackson serialisation filter framework which provides the ability to add conditional logic, through SpEL, to dynamically suppress fields serialised into json.

CircleCI

Usage

  1. Enable the SpEL filter by annotating your application configuration or main class with the @EnableJacksonSpELFilter. This will add an ObjectMapper bean tot he context, if there isn't one already, and add an instance of the SpELPropertyFilterImpl named 'spel'.
  2. Annotate the type in which the SpEL Filter will be applied with the JsonFilter annotation - @JsonFilter('spel').
  3. Annotate the fields within the class declared in 2, which are required to be conditionally suppressed, with the JsonFilterExpression annotation and declare the expression which will be evaluated to decide whether to suppress the field in json output.