Gson解析List和Map类型的Json串

list类型

List<PrizeInfos> rs=new ArrayList<PrizeInfos>();
Type type = new TypeToken<ArrayList<PrizeInfos>>() {}.getType();
rs=gson.fromJson(current.getPrizeInfos(), type);

map类型

  Map<String, City> citys = gson.fromJson(jsonStr, new TypeToken<Map<String, City>>() {}.getType()); 

猜你喜欢

转载自blog.csdn.net/qq_31344725/article/details/77880398