xmlmapper usewrapping new jacksonxmlelementwrapper false deserializar java json jackson fasterxml

java - usewrapping - xml to json jackson



@XMLElementWrapper problema con com.fasterxml.jackson JacksonJaxbJsonProvider (0)

Estoy tratando de obtener el JSON correcto para

public class MyTestResponse { @XmlElementWrapper(name = "data") @XmlElement(name = "values") public List<String> test = Arrays.asList("Sidney"); }

Ahora obtengo

"values": [ "Sidney" ],

en lugar de

"data":{ "values": [ "Sidney" ] },

Por lo tanto, el elemento contenedor "datos" no está presente.

Estoy usando com.fasterxml.jackson stack (2.8.6) dentro de ServiceMix 7 M3.

Mi proveedor JSON amplía com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider:

import com.fasterxml.jackson.databind.AnnotationIntrospector; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; @Provider @Consumes({ MediaType.APPLICATION_JSON, "text/json" }) @Produces({ MediaType.APPLICATION_JSON, "text/json" }) public class JsonProvider extends JacksonJaxbJsonProvider { public JsonProvider() { super(); ObjectMapper mapper = new ObjectMapper(); AnnotationIntrospector primary = new JaxbAnnotationIntrospector(mapper.getTypeFactory()); AnnotationIntrospector secondary = new JacksonAnnotationIntrospector(); AnnotationIntrospector pair = AnnotationIntrospector.pair(primary, secondary); mapper.setAnnotationIntrospector(pair); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.disable(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED); mapper.disable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); this.setMapper(mapper); } }

¿Cómo puedo decirle al JacksonJaxbJsonProvider que represente el elemento envoltorio alrededor del elemento de valores?