Gson解析List和Map类型的Json串

来源:互联网 发布:网络大学专升本 编辑:程序博客网 时间:2024/06/16 03:43

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()); 

阅读全文
0 0