Map<Long,List<Person>> map=new HashMap<Long,List<Person>>(); //adding some dataGson gson=new Gson();String mapJsonStr=gson.toJson(map);//mapJsonStr : is my map's JSon Strin
反向
TypeToken<Map<Long,List<Person>>> token = new TypeToken<Map<Long,List<Person>>>(){}; Map<Long,List<Person>> map_new=new HashMap<Long,List<Person>>(); map_new=gson.fromJson(mapJsonStr,token.getType()); //origian map// map_new is my Map get from map's Json String
就是这样,谢谢
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)