Reputation: 1330
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?
Upvotes: 4
Views: 5371
Reputation: 20125
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;
Upvotes: 12