title: Json deserialization into other class hierarchy using Jackson
body: <p>Now i'm working with Jackson and i have some questions about it.</p>
  
  <p>First of all. I have two services, first is data collecting and sending service and second receive this data and, for example, log it into a file.</p>
  
  <p>So, first service has class hierarchy like this:</p>
  
  <pre><code>         +----ConcreteC
           |
  Base ----+----ConcreteA
           |
           +----ConcreteB
  </code></pre>
  
  <p>And second service has class hierarchy like this:</p>
  
  <pre><code>ConcreteAAdapter extends ConcreteA implements Adapter {}
  ConcreteBAdapter extends ConcreteB implements Adapter {}
  ConcreteCAdapter extends ConcreteC implements Adapter {}
  </code></pre>
  
  <p>The first service knows nothing about <code>ConcreteXAdapter</code>.</p>
  
  <p>The way i'm sending the data on the first service:</p>
  
  <pre><code>Collection&lt;Base&gt; data = new LinkedBlockingQueue&lt;Base&gt;()
  JacksonUtils utils = new JacksonUtils();
  data.add(new ConcreteA());
  data.add(new ConcreteB());
  data.add(new ConcreteC());
  ...
  send(utils.marshall(data));
  ...
  
  public class JacksonUtils {
  
      public byte[] marshall(Collection&lt;Base&gt; data) throws IOException {
          ByteArrayOutputStream out = new ByteArrayOutputStream() {
              @Override
              public byte[] toByteArray() {
                  return buf;
              }
          };
  
          getObjectMapper().writeValue(out, data);
          return out.toByteArray();
      }
      protected ObjectMapper getObjectMapper() {
          return new ObjectMapper();
      }
  
      public Object unmarshall(byte[] json) throws IOException {
          return getObjectMapper().readValue(json, Object.class);
      }
  
      public &lt;T&gt; T unmarshall(InputStream source, TypeReference&lt;T&gt; typeReference) throws IOException {
          return getObjectMapper().readValue(source, typeReference);
      }
  
      public &lt;T&gt; T unmarshall(byte[] json, TypeReference&lt;T&gt; typeReference) throws IOException {
          return getObjectMapper().readValue(json, typeReference);
      }
  }
  </code></pre>
  
  <p>So, i want to desirialize json into Collection of <code>ConcreteXAdapter</code>, not into Collection of <code>ConcreteX</code> (<code>ConcreteA -&gt; ConcreteAAdapter, ConcreteB -&gt; ConcreteBAdapter, ConcreteC -&gt; ConcreteCAdapter</code>). In the case i described i want to get:</p>
  
  <pre><code>Collection [ConcreteAAdapter, ConcreteBAdapter, ConcreteCAdapter]
  </code></pre>
  
  <p>How can i do this?</p>