java@JsonInclude(Include.NON_NULL)不会从内部POJO中删除NULL字段
我的回答结构如下。我正在使用jackson-databind
版本2.5.1
public class MyResponse {
private String entity;
private Detail detail;
// public Getter and setter
}
@JsonInclude(Include.NON_NULL)
public class Detail {
private String name;
private String location; // location field is null for testing
// public Getter and setter
}
问题:响应包括location
字段,即使它是null
注意:@JsonInclude
适用于外部对象,即MyResponse,但不适用于内部POJO类
多谢各位
共 (0) 个答案