我正在尝试使 jackason 的 thrift 反序列化向后兼容
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
不行?
Jackson Bind不支持吗FAIL_ON_UNKNOWN_PROPERTIES
为了节俭?