I have a model class like this:
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Defect
and I need JsonInclude.Include.NON_NULL
to ignore the null
values. But I have a property that needs to be null
sometimes.
@JsonProperty("blocked")
private String blocked;
Is there a way I can dynamically (at run-time) set this value to be included or not?
You should be able to override the class-level @JsonInclude
with a field-level @JsonInclude
, as follows:
@JsonInclude(JsonInclude.Include.ALWAYS)
@JsonProperty("blocked")
private String blocked;
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