How to dynamically ignore fields while serializing java objects to json use jackson and spring boot

When we developed the Restful API, the returned data was usually in JSON format, to ignore fields while serializing POJO objects to json, the Jackson library provides two annotations: @JsonIgnore and @JsonIgnoreProperties to ignore fields. But both these annotations need the fields at compile time itself. We want the fields to be ignored have to be decided at the runtime, based on the endpoint called.
The following tutorial will solve this problem:

Continue reading “How to dynamically ignore fields while serializing java objects to json use jackson and spring boot”