views:

17

answers:

1

API publisher added new field to their response object that isn't in my model classes. Is there a way to loosen up the mapper to ignore unknown fields? I still want to use my old legacy model classes to parse, but now I get an exception...

A: 

Switch to Jackson JSON Processor and do this:

ObjectMapper mapper = new ObjectMapper();

// THIS IS WHAT I WAS LOOKING FOR TO HANDLE IN XSTREAM!!!!!!
mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

User user = mapper.readValue(new File("user.json"), User.class);
Eli