package com.fasterxml.jackson.databind.jsontype; import java.util.List; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.module.SimpleModule; public class AbstractTypeMapping1186Test extends BaseMapTest { public interface IContainer { @JsonProperty("ts") List getTs(); } static class MyContainer implements IContainer { final List ts; @JsonCreator public MyContainer(@JsonProperty("ts") List ts) { this.ts = ts; } @Override public List getTs() { return ts; } } public static class MyObject { public String msg; } public void testDeserializeMyContainer() throws Exception { SimpleModule module = new SimpleModule().addAbstractTypeMapping(IContainer.class, MyContainer.class); final ObjectMapper mapper = new ObjectMapper().registerModule(module); String json = "{\"ts\": [ { \"msg\": \"hello\"} ] }"; final Object o = mapper.readValue(json, mapper.getTypeFactory().constructParametricType(IContainer.class, MyObject.class)); assertEquals(MyContainer.class, o.getClass()); MyContainer myc = (MyContainer) o; assertEquals(1, myc.ts.size()); Object value = myc.ts.get(0); assertEquals(MyObject.class, value.getClass()); } }