在进行序列化如何过滤为null的属性,empty的属性,或者default的属性. 一.全局注册 objectMapper.setSerializationInclusion(Include.ALWAYS); 二.具体类上打注解 @JsonSerialize(include = Inclusion.NON_NULL) public class MyTypeWithoutNulls { public String mayHaveValue; // will not be included if v…
一个pojo类: import lombok.Data; @Data public class Friend { private String name; private int age; private String sex; } 初始化一个Friend对象,该对象属性为"sex"对应的值设置为null: public class FriendTest { private Friend friend = new Friend(); @Before public void init()…