我@JsonInclude(Include.NON_NULL)
在Response类上添加了注释。
@JsonInclude(Include.NON_NULL)
public class Response {
@JsonProperty
private String message;
// getter-setters
}
如果该值为null,则该属性不包含在JSON中
但是我仍然将此属性作为NULL。
{
"message": null
}
可能是什么原因?我有什么想念的吗?
我试过了
@JsonSerialize(include = Inclusion.NON_NULL)
的
@JsonInclude(Include.NON_NULL)
并按预期工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句