0

I am using a Spring 4 MVC application. I want to configure Jackson using Java Config method, specifically to set the wrap_root_value property but I can't figure out how to do it.

Can someone please provide assistance. Thanks

John Steed
  • 599
  • 1
  • 12
  • 31
  • I'm assuming you're not using Spring Boot. Does this help? http://stackoverflow.com/questions/4823358/spring-configure-responsebody-json-format – Nazaret K. Apr 27 '16 at 21:23

1 Answers1

1

You can create one objectMapper which extends the codehaus like -

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);
    }
}
Sai prateek
  • 11,842
  • 9
  • 51
  • 66