I have the code below... I want Jackson to ignore the @JsonFilter on a class in the else condition below. I only want it to consider the @JsonFilter in the event I have some filters.
@JsonFilter("filter")
public class Test {
}
if (filters != null)
mapper.writer(filters).writeValue(jsonGenerator,
response.getOriginalResponse());
else
mapper.writeValue(jsonGenerator, response.getOriginalResponse());
I did this to bypass the filter in the else condition.
SimpleFilterProvider dummy = new SimpleFilterProvider();
dummy.setFailOnUnknownId(false);
mapper.writer(dummy).writeValue(jsonGenerator,
response.getOriginalResponse());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With