--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public ObjectMapper create() {
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, "@class");
CustomTypeResolverBuilder resolverBuilder = new CustomTypeResolverBuilder();
resolverBuilder.init(JsonTypeInfo.Id.CLASS, null).inclusion(JsonTypeInfo.As.PROPERTY);
resolverBuilder.typeProperty("@Class");
mapper.setDefaultTyping(resolverBuilder);
SubtypeResolver subtypeResolver = mapper.getSubtypeResolver();
subtypeResolver.registerSubtypes(new NamedType(uvw.class, "Uvw"));
subtypeResolver.registerSubtypes(new NamedType(xyz.class, "Xyz"));
mapper.setSubtypeResolver(subtypeResolver);
return mapper;
}
--
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.2.3</version>
org.codehaus.jackson.map.JsonMappingException: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class org.example.AbstractSuperclass
at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@79c6d8; line: 1, column: 1]
at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163) ~[jackson-mapper-asl-1.9.9.jar:1.9.9]
I already consulted these guides:
http://wiki.fasterxml.com/JacksonPolymorphicDeserialization
http://stackoverflow.com/questions/10329706/json-deserialization-into-another-class-hierarchy-using-jackson (Mixin approach is also interesting for the generated transfer objects that I cannot manipulate)
Hi Tatu,
thanks for the clarification that was what I already guessed. I managed to eliminate all codehaus (1.x) dependencies and references and it turned out that there was a mixture of 1.x and 2.x code causing the problem.
I use mixin approach to define the annotations in an inner config class and mix it into the generated classes.
Works like a charm.
Also I am working on a generic datatype support in an OSS project (see https://github.com/m-m-m/mmm/blob/master/mmm-util/mmm-util-core/src/main/java/net/sf/mmm/util/lang/api/DatatypeDescriptorManager.java and https://github.com/m-m-m/mmm/blob/master/mmm-util/mmm-util-core/src/test/java/net/sf/mmm/util/lang/base/datatype/descriptor/DatatypeDescriptorManagerTest.java) and will write a generic bridge for JAXB (XMLAdapter), Jackson (JsonDeserializer and JsonSerializer) and Hibernate (UserType) based on this.
Thanks for your support...