Why is Jackson wrapping my objects with an extra layer named after the class?
When I serialize
public class FOO {
int field1;
String开发者_如何学编程 field2;
}
I got the following.
{"FOO":{"field1":0,"field2":"value"}}
Can you point me how can I make the output look like this
{"field1":0,"field2":"value"}
I've figured out how to make it. Actually the problem is that MappingJacksonJsonView has a map So that's why it returns it that way {"FOO":{"field1":0,"field2":"value"}}
But If I configured it that way
<beans:bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
<beans:property name="extractValueFromSingleKeyModel" value="true" />
</beans:bean>
It will serialize the object itself not the whole map. I hope it will help someone else.
精彩评论