I have class
@Data
public class MyClass {
private Boolean flag;
}
And want to convert it to XML. However I need to ignore flag field during serialization if flag is not true.
So if flag=true, I want to get:
<MyClass><flag>true</flag></MyClass>
Otherwise(if flag==null or flag==false), I want to get:
<MyClass></MyClass>
How can I do it?
I tried @JsonInclude(JsonInclude.Include.NON_NULL), but it works only for null values.