users@jersey.java.net

[Jersey] Deserializing nested objects

From: António Mota <amsmota_at_gmail.com>
Date: Thu, 24 Nov 2011 11:14:02 +0000

Hi again.

I'm trying to deserialize a List of custom objects that in turn has other
custom objects as properties. All the object classes are annotated with
JAXB.

config = new DefaultClientConfig();
config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
Boolean.TRUE);
client = Client.create(config);
service = client.resource("http://localhost:8080/rest");
(...)
service.path("/image/").path(imageId).accept(MediaType.APPLICATION_JSON).get(new
GenericType<List<Image>>(){});


Now the Image definition has

@XmlJavaTypeAdapter(AnyTypeAdapter.class)
private BoxCoordinates coordinates;


when trying to deserialize I got the following:


Problem deserializing property 'coordinates' (expected type: [simple type,
class BoxCoordinates]; actual type: java.util.LinkedHashMap), problem: Can
not set BoxCoordinates field Image.coordinates to java.util.LinkedHashMap
(through reference chain: Image["coordinates"])


I tried different approaches, like not using the FEATURE_POJO_MAPPING, with
and without adding JacksonProviderProxy to config.getClasses(),
trying different Providers including a custom one, to create a
custom ObjectMapper, nothing worked.


Any ideas?

Thanks.



**
* Melhores cumprimentos / Beir beannacht / Best regards
**______________________________________________________*
*António Manuel dos Santos Mota
http://gplus.to/amsmota
**http://www.cardcloud.com/amsmota**
**______________________________________________________*
**