java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to
·
第一种方法不行则使用第二种
public static List<?> jsonToList(String jsonStr) {
List<?> objList = null;
if (gson != null) {
Type type = new TypeToken<List<?>>() {
}.getType();
objList = gson.fromJson(jsonStr, type);
}
return objList;
}
public static List<?> jsonToList(String jsonStr, Type type) {
List<?> objList = null;
if (gson != null) {
objList = gson.fromJson(jsonStr, type);
}
return objList;
}
例如:
List<FloorBean> floorBeans = (List<FloorBean>) GsonUtil.jsonToList(tempResponse, new TypeToken<List<FloorBean>>() {
}.getType());
更多推荐

所有评论(0)