title: Using generics with GSON
body: <p>I am using GSON to decode JSON into an object of type T e.g.</p>
  
  <pre><code>public T decode(String json) {
      Gson gson = new Gson();
      return gson.fromJson(json, new TypeToken&lt;T&gt;() {}.getType());
  }
  </code></pre>
  
  <p>This however returns an exception - </p>
  
  <p>java.lang.AssertionError: Unexpected type. 
  Expected one of: 
  java.lang.reflect.ParameterizedType,
  java.lang.reflect.GenericArrayType,
  but got: sun.reflect.generics.reflectiveObjects.TypeVariableImpl, for type token: T</p>
  
  <p>I thought that by using TypeToken I avoided Type Erasure.</p>
  
  <p>Am I wrong?</p>
  
  <p>Thanks</p>