I'm using the jackson library to map JSON into objects. I've simplified the problem a lot, this is what happens:
public class MyObject{
public ForeignCollection<MySecondObject> getA(){
return null;
}
public ForeignCollection<MyThirdObject> getB(){
return null;
}
}
I'm parsing the an empty JSON string:
ObjectMapper mapper = new ObjectMapper();
mapper.readValue("{}", MyObject.class);
On readValue
, I get this Exception:
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]]
This happens when I have two get
methods in the MyObject
class which return a ForeignCollection
. Removing one of the get
methods results in no exceptions.
I'm actually surprised by the fact that the mapper looks at the get
methods, it should just set the fields I indicate.
What is happening here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…