我正在使用杰克逊库将 JSON 映射到对象中。我已经简化了很多问题,这就是发生的事情:
public class MyObject{
public ForeignCollection<MySecondObject> getA(){
return null;
}
public ForeignCollection<MyThirdObject> getB(){
return null;
}
}
我正在解析一个空的 JSON 字符串:
ObjectMapper mapper = new ObjectMapper();
mapper.readValue("{}", MyObject.class);
上readValue
,我得到这个异常:
com.fasterxml.jackson.databind.JsonMappingException: Can not find a deserializer for non-concrete Collection type [collection type; class com.j256.ormlite.dao.ForeignCollection, contains [simple type, class com.test.MyThirdObject]]
当我在类中有两个 返回 a 的get
方法时会发生这种情况。删除其中一种方法不会导致异常。MyObject
ForeignCollection
get
实际上,我对映射器查看get
方法的事实感到惊讶,它应该只设置我指示的字段。
这里发生了什么?