You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And I use the MappingJackson2HttpMessageConverter as an ObjectMapper.
The result of requesting my controller's method is:
{
"content": {
}
}
But in case of Test class is an @entity or a @component, it serialized correctly:
{ }
The reason of such behaviour is that Jackson uses UnwrappingBeanSerializer to serialize @entity and unwrap "content" property, but in case of POJO Jackson uses UnknownSerializer that serialize content as is.
The problem can be solved by setting @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY) class annotation on TestMixIn, but it looks like a hack.
The text was updated successfully, but these errors were encountered:
Any chance you provide a test case that shows what exactly is failing? I get a bit lost in "Test class" and @entity and serializers you all mention but can't really wrap my hand around.
Hi,
here is my controller code:
And I use the MappingJackson2HttpMessageConverter as an ObjectMapper.
The result of requesting my controller's method is:
{ "content": { } }
But in case of Test class is an @entity or a @component, it serialized correctly:
The reason of such behaviour is that Jackson uses UnwrappingBeanSerializer to serialize @entity and unwrap "content" property, but in case of POJO Jackson uses UnknownSerializer that serialize content as is.
The problem can be solved by setting @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY) class annotation on TestMixIn, but it looks like a hack.
The text was updated successfully, but these errors were encountered: