title: Jackson determine subclass for list field
body: <pre class="lang-java prettyprint-override"><code>@Data
  public class Parent {
      private String type;
      private List&lt;ChildBase&gt; children;
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>public abstract class ChildBase {
      public void someMethod(){};
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@Data
  public class ChildA extends ChildBase {
      private String bar;
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@Data
  public class ChildB extends ChildBase {
      private String foo;
  }
  </code></pre>
  
  <p>Then, the original JSON string is:</p>
  
  <pre><code>{
    "type": "childA",
    "children": [
      {
         "bar": "baaaar"
      }
    ]
  }
  </code></pre>
  
  <p>How can I deserialize this JSON string, the deserialized object(instance of <code>Parent</code>), its <code>children</code> field's actual type should be <code>ChildA</code>, because the <code>type</code> field specified;</p>
  
  <p>In the question <a href="https://stackoverflow.com/questions/4574952/use-property-of-parent-object-to-determine-subclass-when-deserializing">use-property-of-parent-object-to-determine-subclass-when-deserializing</a>, the answer blow shows the way to determine subclass, by it doesn't work with a list field.</p>