jsonArray转换成list



 /**
  * 将JSONArray 转换为map list
  * @param jA
  * @return List
  * @throws JSONException
  */
 public static List<Map<String, String>> jSONArrayToMapList(JSONArray jA) throws JSONException {

  List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  for (int i = 0; i < jA.length(); i++) {
   Map<String, String> map = new HashMap<String, String>();
   JSONObject jSONObject = (JSONObject) jA.get(i);
   Iterator<?> it = jSONObject.keys();
   while (it.hasNext()) {
    Object key = it.next();
    // Object value=jSONObject.get(key);
    if (key != null && !"".equals(key)) {
     map.put(key.toString(),jSONObject.get(key.toString()).toString());
    }
   }
   list.add(map);
  }
  return list;
 }

你可能感兴趣的:(jsonArray转换成list)