users@jersey.java.net

[Jersey] Ignore unknown JSON properties

From: Tauren Mills <tauren_at_groovee.com>
Date: Mon, 28 Mar 2011 21:58:02 -0700

Is there a way to prevent an exception from being thrown if there are extra
properties in the JSON data sent to a resource? If there are any properties
in the JSON that do not map to the POJO, and exception gets thrown. I want
to just ignore those properties.

@Consumes(MediaType.APPLICATION_JSON)
public Response createItem(ItemDTO dto) {
    ...
}

public class ItemDTO {
   String name;
}

JSON:
{name: "Item 1", junk: "Property not in POJO"}

An exception is thrown because ItemDTO.junk doesn't exist. How can I ignore
extra properties?

Thanks,
Tauren