We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
以前返回数据是这样 [{ id:123, name:'zz', uname:null }]
现在是这样 [{ id:123, name:'zz' }]
The text was updated successfully, but these errors were encountered:
查看类:JacksonJsonRopMarshaller private ObjectMapper getObjectMapper() throws IOException { if (this.objectMapper == null) { ObjectMapper objectMapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(); SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); serializationConfig = serializationConfig.without(SerializationConfig.Feature.WRAP_ROOT_VALUE) .with(SerializationConfig.Feature.INDENT_OUTPUT) .withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL) .withSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY) .withAnnotationIntrospector(introspector).withDateFormat(getDateFormat()); objectMapper.setSerializationConfig(serializationConfig); this.objectMapper = objectMapper; } return this.objectMapper; } .withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL) // 此设置代表对象域为null,不输出 .withSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY) // 此设置代表对象域为空字符串,不输出 可注释掉这两处,重新打包
private ObjectMapper getObjectMapper() throws IOException { if (this.objectMapper == null) { ObjectMapper objectMapper = new ObjectMapper(); AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(); SerializationConfig serializationConfig = objectMapper.getSerializationConfig(); serializationConfig = serializationConfig.without(SerializationConfig.Feature.WRAP_ROOT_VALUE) .with(SerializationConfig.Feature.INDENT_OUTPUT) .withSerializationInclusion(JsonSerialize.Inclusion.NON_NULL) .withSerializationInclusion(JsonSerialize.Inclusion.NON_EMPTY) .withAnnotationIntrospector(introspector).withDateFormat(getDateFormat()); objectMapper.setSerializationConfig(serializationConfig); this.objectMapper = objectMapper; } return this.objectMapper; }
Sorry, something went wrong.
No branches or pull requests
以前返回数据是这样
[{
id:123,
name:'zz',
uname:null
}]
现在是这样
[{
id:123,
name:'zz'
}]
The text was updated successfully, but these errors were encountered: