title: Gson: parse generic collections
body: <p>Is it possible to create a method, that parses a generic collection from jsson? My aproach above doesn't work, because at runtime gson returns an ArrayList of LinkedHasmaps here, however there is no errors at compile time.</p>
  
  <pre><code>private &lt;T&gt; ArrayList&lt;T&gt; readArray(String json)
  {
      Gson gson = new Gson();
      Type collType = new TypeToken&lt;ArrayList&lt;T&gt;&gt;() {
      }.getType();
      return gson.fromJson(json, collType);
  }
  </code></pre>
  
  <p>I have already looked at some similar questions here like: <a href="https://stackoverflow.com/questions/5370768/using-a-generic-type-with-gson">Using a generic type with Gson</a>, but I found no solution, that really works. </p>