Is there a way to enable/disable the UNWRAP_ROOT_VALUE
and WRAP_ROOT_VALUE
in Jackson's ObjectMapper
dynamically.
I have to enable/disable these properties depending on what service is called, some requests require a JsonRootName
and some do not.
I have the @JsonRootName
annotation in the classes that do require it.
I have a custom ObjectMapper
class that extends the Jackson Object mapper.
I am calling a method to enable/disable the properties depending on what service is called but is it doesn't seem to be working.
public void setWrapValue(boolean wrap) {
final AnnotationIntrospector introspector = new JacksonAnnotationIntrospector();
this.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, wrap);
this.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, wrap);
this.setDeserializationConfig(this.getDeserializationConfig().withAnnotationIntrospector(introspector));
this.setSerializationConfig(this.getSerializationConfig().withAnnotationIntrospector(introspector));
}