I have a List in a Java Pojo class. That list contains some MyChildPojo objects which are not null but can have properties with null values. Example:
MyChildPojo obj1 = new MyChildPojo();
MyChildPojo obj2 = new MyChildPojo();
I have added @JsonInclude(JsonInclude.Include.NON_EMPTY)
on my MyChildPojo class so null properties will not be added while serializing the object.
Now my final serialized output for the List object is:
[
{}, {}
]
I want to remove the complete List object in this case. I have tried by adding @JsonInclude(JsonInclude.Include.NON_EMPTY)
and @JsonInclude(value = Include.NON_EMPTY, content = Include.NON_EMPTY)
on the List object but still getting the same output.
I can only use annotation in my case. Is there any possible way to do this?