title: Deserializing Generic Types with GSON
body: <p>I have some problems with implementation of Json Deserialization in my Android application (with Gson library)</p>
  
  <p>I've made class like this</p>
  
  <pre><code>public class MyJson&lt;T&gt;{
      public List&lt;T&gt; posts;
  }
  </code></pre>
  
  <p>And Deserialization call is:</p>
  
  <pre><code>public class JsonDownloader&lt;T&gt; extends AsyncTask&lt;Void, Void, MyJson&lt;T&gt;&gt; {
  ...
  protected MyJson&lt;T&gt; doInBackground(Void... params) {
    ...
      Reader reader = new InputStreamReader(content);
      GsonBuilder gson = new GsonBuilder();
      Type collectionType = new TypeToken&lt;MyJson&lt;T&gt;&gt;() {}.getType();
      result = gson.create().fromJson(reader, collectionType);
    ...
    }
  }
  </code></pre>
  
  <p>Problem is that result.posts list after call holds one Array of LinkedTreeMap Objects(with correct values so problem is Deserialization) instead of MyJson Objects. When I use MyObject instead of T everything is running fine and MyObject is correct.</p>
  
  <p>So is there any way to implement deserialization call without creating custom deserializer?</p>