0
我正在使用Spring 4 MVC应用程序。我想用Java Config方法配置Jackson,特别是设置wrap_root_value属性,但我无法弄清楚如何去做。配置Jackson使用Spring 4 Java Config
有人可以提供帮助。由于
我正在使用Spring 4 MVC应用程序。我想用Java Config方法配置Jackson,特别是设置wrap_root_value属性,但我无法弄清楚如何去做。配置Jackson使用Spring 4 Java Config
有人可以提供帮助。由于
您可以创建扩展了Codehaus的像一个objectMapper -
public class JaxbJacksonObjectMapper extends ObjectMapper {
public JaxbJacksonObjectMapper() {
final AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
this.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
super.getDeserializationConfig().withAnnotationIntrospector(introspector);
this.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
super.getSerializationConfig().withAnnotationIntrospector(introspector);
}
}
这正是我需要的。谢谢 –
我假设你没有使用Spring启动。这有帮助吗? http://stackoverflow.com/questions/4823358/spring-configure-responsebody-json-format –