API发布商将新字段添加到不在我的模型类中的响应对象。有没有办法放松映射器来忽略未知字段?我仍然希望使用旧的遗留模型类进行解析,但现在我得到了一个例外......
答案 0 :(得分:0)
切换到Jackson JSON处理器并执行此操作:
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);