samedi 28 mars 2015

Custom object deserializes fine in Jax-RS but if it is used in another object it doesn't work



Deserializing works fine if I just pass my custom object through



@POST
public Response saveCustomObject(CustomObject data)
{
// Prints correct value
System.out.println(data);
}


However, if it is a property on another object, it just gets the default value of my custom object



@POST
public Response saveCustomObjectWrapper(CustomObjectWrapper data)
{
// Prints incorrect value
System.out.println(data.getCustomObject());
}


My provider is registered and looks like this:



public CustomObject readFrom(Class<CustomObject> type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap<String, String> mm, InputStream in) throws IOException, WebApplicationException
{
try {
return new CustomObject(IOUtils.toString(in));
} catch (Exception ex) {
throw new ProcessingException("Error deserializing a CustomObject.", ex);
}
}



Aucun commentaire:

Enregistrer un commentaire