title: GSON: java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to My Generic Class
body: <p>Made one example that show my problem.
  May be somebody have any idea ?</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ClassCastException:
    com.google.gson.internal.LinkedTreeMap cannot be cast to
    JSONClassResponse     at Main.main(Main.java:8)   at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)     at
    com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)</p>
  </blockquote>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
  
          GetJSON&lt;JSONClassResponse&lt;JSONClass&gt;&gt; getJSON = new GetJSON&lt;&gt;();
          JSONClassResponse&lt;JSONClass&gt; jsonResult = getJSON.get();
          System.out.println(jsonResult);
  
      }
  }
  
  import com.google.gson.Gson;
  import com.google.gson.GsonBuilder;
  import com.google.gson.reflect.TypeToken;
  import java.lang.reflect.Type;
  
  public class GetJSON&lt;T&gt; {
      public T get() {
          String buf = "{errcode:1,data:{value:[v1,v2,v3]}}"; // instant http request
  
          GsonBuilder gsonBuilder = new GsonBuilder();
          Gson gson = gsonBuilder.create();
  
          Type tType = new TypeToken&lt;T&gt;() {
          }.getType();
          T t = gson.fromJson(buf, tType);
          return t;
      }
  }
  
  import com.google.gson.annotations.SerializedName;
  public class JSONClassResponse&lt;T&gt; {
  
      @SerializedName("errcode")
      private String errcode;
  
      @SerializedName("data")
      private T data;
  }
  
  import com.google.gson.annotations.SerializedName;
  import java.util.List;
  
  public class JSONClass {
  
      @SerializedName("value")
      private List&lt;String&gt; value = null;
  
  }
  </code></pre>