Open
Description
Hi,
here is my controller code:
@RequestMapping(value= "/test-resource", method = RequestMethod.GET)
public TestResource test() {
return new TestResource(new Test());
}
private class TestResource extends Resource<Test> {
public TestResource(Test content, Link... links) {
super(content, links);
}
}
private class Test {}
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.