@JsonInclude(JsonInclude.Include.NON_NULL)注解
1. 用法含义:为null的字段不序列化2. 示例@JsonInclude(JsonInclude.Include.NON_NULL)public class Response {private String name;private String targetId;private String characteristic;}假设这个Response类是返回给前端的响应。如果字段characte
·
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"
}
更多推荐
已为社区贡献1条内容
所有评论(0)