I am using jackson library to map JSON to objects. I greatly simplified the problem, here is what happens:
public class MyObject{ public ForeignCollection<MySecondObject> getA(){ return null; } public ForeignCollection<MyThirdObject> getB(){ return null; } }
I am parsing an empty JSON string:
ObjectMapper mapper = new ObjectMapper(); mapper.readValue("{}", MyObject.class);
In 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 that return a ForeignCollection . Removing one of the get methods does not throw an exception.
I am really surprised that the handler is looking at get methods, it should just set the fields that I specify.
What's going on here?
json android jackson ormlite
nhaarman
source share