我正在尝试进行thrift反序列化以使jackason向后兼容
ObjectMapper mapper = getObjectMapper(false /* pretty */);
mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true); // This works
// This doesn't work
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MapLikeType t = mapper.getTypeFactory().constructMapLikeType(LinkedHashMap.class, keyClass, valueClass);
return mapper.readValue(content, t);
valueClass
属于以下类型
public class MyThrift implements org.apache.thrift.TBase<MyThrift, MyThrift._Fields>, java.io.Serializable, Cloneable, Comparable<MyThrift> {
我一直在
com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of com.MyThrift$_Fields from String value 'MY_ID': value not one of declared Enum instance names
如果我使用FAIL_ON_UNKNOWN_PROPERTIES
但是,如果我使用READ_UNKNOWN_ENUM_VALUES_AS_NULL
,我不会得到同样的错误,有人能指出我为什么使用FAIL_ON_UNKNOWN_PROPERTIES
不起作用的方向?
Jackason绑定不支持FAIL_ON_UNKNOWN_PROPERTIES
节俭吗?