1. 用法含义:为null的字段不序列化
2. 示例
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response {
private String name;
private String targetId;
private String characteristic;
}
假设这个Response类是返回给前端的响应。如果字段characteristic为null,加上该注解后前端拿到的响应格式应该是这个样子(为null的characteristic字段不会显示在序列化结果里):
{
"name": "xxx",
"targetId": "xxx"
}