Jackson

xiaoxiao2021-02-28  30

Jackson 常用注解:

忽略为Null的属性:

@JsonInclude(JsonInclude.Include.NON_NULL) 

指定忽略哪个属性:

@JsonIgnore

属性为 空(“”) 或者为 NULL 都不序列化 :

@JsonInclude(JsonInclude.Include.NON_EMPTY) 

若要通过代码设定:

ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL);
转载请注明原文地址: https://www.6miu.com/read-2613984.html

最新回复(0)