title: Generic method and JSON
body: <p>I wrote generic method which returns list of some objects, for example Orders. My question is why in second, non-generic method it returns correct list of Orders and the first method (generic) returns list of linkedHashMaps instead of Orders?</p>
  
  <p>Generic:</p>
  
  <pre><code> private &lt;T&gt; List&lt;T&gt; mapObjectsToList(String objectsListInJson) throws IOException {
      ObjectMapper objectMapper = new ObjectMapper();
      TypeReference&lt;List&lt;T&gt;&gt; mapType = new TypeReference&lt;List&lt;T&gt;&gt;() {
      };
      return objectMapper.readValue(objectsListInJson, mapType);
  }
  </code></pre>
  
  <p>Non-generic:</p>
  
  <pre><code>private List&lt;Order&gt; mapObjectsToList(String objectsListInJson) throws IOException {
      ObjectMapper objectMapper = new ObjectMapper();
      TypeReference&lt;List&lt;Order&gt;&gt; mapType = new TypeReference&lt;List&lt;Order&gt;&gt;() {
      };
      return objectMapper.readValue(objectsListInJson, mapType);
  }
  </code></pre>
  
  <p>Generic method returns that:
  <a href="https://i.stack.imgur.com/I6HpK.png" rel="nofollow noreferrer">LinkedHashMap</a></p>