java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to

java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to


public class ApiListResponseBase{

    public String  message;
    public boolean  status;
    public Data data;

    public class Data {
        public int total;
        public List list;
    }
}

使用泛型进行类转换时发生转换异常的错误,这个是里面的list泛型没有转换成功,修改如下


public class ApiListResponseBase{

    public String  message;
    public boolean  status;
    public Data data;

    public static class Data {
        public int total;
        public List list;
    }
}

内部类需要加上static 才可以转换

你可能感兴趣的:(java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to)