I use jackson for converting JSON to Object class.
JSON:
{
"aaa":"111",
"bbb":"222",
"ccc":"333"
}
Object Class:
class Test{
public String aaa;
public String bbb;
}
Code:
ObjectMapper mapper = new ObjectMapper();
Object obj = mapper.readValue(content, valueType);
My code throws exception like that:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "cccc" (Class com.isoftstone.banggo.net.result.GetGoodsInfoResult), not marked as ignorable
And I don't want to add a prop to class Test,I just want jackson convert the exist value whith is also exist in Test.
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
instead. – Quisling