如:
jsonData的数据格式:[{ "name": "xiaowang", "password": "123" },{ "name": "xiaozhang", "password": "456" },{ "name": "xiaoli", "password": "789" }]
import org.json.JSONArray; import org.json.JSONObject;
private JSONArray arr; arr = new JSONArray(jsonData); for(int i=0;i<arr.length();++i){ JSONObject temp = (JSONObject) arr.get(i); map.clear(); map.put("materialName", temp.getString("materialName")); map.put("materialFormat", temp.getString("unitName")); map.put("id", temp.getString("id")); listItem.add(map); }