I don't want to include nested objects values in json which are null, but I obtain different result. I have class:
@Data
public class HoldsType {
    @JsonInclude(JsonInclude.Include.NON_NULL)
    protected HoldTypeIndicatorType holdTypeIndicator;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    protected HoldReasonsType holdReasons;
}
And it contains nested HoldTypeIndicatorType class:
@Data
public class HoldTypeIndicatorType {
    @JsonInclude(JsonInclude.Include.NON_NULL)
    protected Boolean dealerAssignment;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    protected Boolean someSpecification;
}
I added there @JsonInclude(JsonInclude.Include.NON_NULL) annotations to exclude those fields from results json, but I receive:
{
 "holdTypeIndicator": {}
}
I tried also adding
- NON_DEFAULT property, or
- NON_ABSETNT property, but it's the same.
The problem is here I have tons of fields type: Boolean.
What should be the simplest way to add this behavior to ObjectMapper to not include this holdTypeIndicator object, when all Boolean nested values are null, in json?
Writing custom Serializable will require adding annotation to all of those fields. Is there any way I can override ObjectMapper default serializer for this?
