title: Spring + Jackson + Deserializing List of Generic Objects
body: <p>I have the following controller:</p>
  
  <pre><code>@RequestMapping(value = "/test/inst/", method = RequestMethod.POST)
  public @ResponseBody ResponseDTO&lt;InstDTO&gt; 
          testPostREST(@RequestBody RequestDTO&lt;InstDTO&gt; instDTO) {
  
      RequestDTO&lt;InstDTO&gt; dto = new RequestDTO&lt;InstDTO&gt;();
  
      ResponseDTO&lt;InstDTO&gt; responseDto = new ResponseDTO&lt;InstDTO&gt;();
      responseDto.setPayload(instDTO.getPayload());
      return responseDto; 
  }
  </code></pre>
  
  <p>with the following request object:</p>
  
  <pre><code>@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
  public class RequestDTO&lt;T&gt; {
  
      private List&lt;T&gt; payload;
  
      public RequestDTO() {
          System.out.println("constructor");
      }
  
      public RequestDTO(List&lt;T&gt; payload) {
          this.payload = payload;
      }
  
      public List&lt;T&gt; getPayload() {
          return payload;
      }
  
      public void setPayload(List&lt;T&gt; payload) {
          this.payload = payload;
      }
  }
  </code></pre>
  
  <p>When the POST comes through and I look the object I get, the payload list has LinkedHashMap objects instead of objects of my DTO type.</p>
  
  <p>How can I make spring+jackson convert the JSON into my DTO object. Bear in mind that I plan to reuse the wrapper ResponseDTO for other lists of objects and that's why I'm using a generic list (List).</p>
  
  <p>Here's the JSON I'm trying.</p>
  
  <pre><code>{
    "payload": [
      {
        "d": "Test 0",
        "id": "abcde",
        "c": "Test 0"
      },
      {
        "d": "Test 1",
        "id": "123",
        "c": "Test 1"
      }
    ]
  }
  </code></pre>