Skip to content
New issue

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

返回的数据空字段怎么都没了呢 ? #14

Open
ceylog opened this issue Apr 16, 2014 · 1 comment
Open

返回的数据空字段怎么都没了呢 ? #14

ceylog opened this issue Apr 16, 2014 · 1 comment

Comments

@ceylog
Copy link

ceylog commented Apr 16, 2014

以前返回数据是这样
[{
id:123,
name:'zz',
uname:null
}]

现在是这样
[{
id:123,
name:'zz'
}]

@atjiucheng
Copy link

查看类: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) // 此设置代表对象域为空字符串,不输出
可注释掉这两处,重新打包

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants