当用Gson解析泛型会报以下错误:
com.google.gson.internal.LinkedTreeMap cannot be cast to
解决办法:
public List fromJsonList(String json) {
List mList=new ArrayList();
Gson gson=new Gson();
JsonArray array=new JsonParser().parse(json).getAsJsonArray();
for(final JsonElement elem :array){
mList.add(gson.fromJson(elem, className));
}
return mList;
}