在序列化MyObject时,我想在运行时决定属性类中包含或不包含空属性。什么是最好的方法来做到这一点?在运行时设置序列化属性
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MyObject {
private String property1;
private DateTime property2;
private Attributes attributes;
}
@Data
public class Attributes {
private String property1;
private String property2;
}
但我需要做条件包括null只在'Attributes'类中,而不在'MyObject'类中。 – Shikhar