JSON数组形式字符串转换为List

//从Package包下的ApplicationResources.properties中取key的值拼接成地址
String wholeUrl = ResourceUtil.getString(key, Package) + url;// 请求地址
//从URL中获取JSON数据
String result = HttpRequest.sendGet(wholeUrl, "");
//取出JSON数据{"dayRange":[{"TOTAL":1,"DATE":"07-18"},{"TOTAL":2,"DATE":"07-19"}]}
JSONObject json = JSONObject.fromObject(result);
//取出dayRange对应的数组[{},{}]
//JSONArray itemData = (JSONArray) json.get(item);
//取出的数组放在list中[{key1=value1,key2=value2},{}]
List> itemList = (List>)json.get(item);

JSON数组形式字符串转换为List>方法:

List> itemList = (List>)json.get(item);

 

List>打印输出效果[{3=dong,2=xiao,1=wang,4=haha},{3=dong,2=xiao,1=wang,4=haha}]

list集合里的有两条map集合,每条map集合中有4个

 

List打印是:[{},{}]

Map打印是:key1=value1,key2=value2

你可能感兴趣的:(JSON数组形式字符串转换为List)