json字符串解析

public List<Map<String, Object>> jsonToArray(String json) {

List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

try {

JSONObject jsonobj = new JSONObject(json);

JSONArray ary = jsonobj.getJSONArray("result");

for (int i = 0; i < ary.length(); i++) {

JSONObject obj = (JSONObject) ary.opt(i);

Map<String, Object> map = new HashMap<String, Object>();

map.put("rid", obj.getString("rid"));

map.put("name", obj.getString("name"));

map.put("wk", obj.getString("wk"));

map.put("wboxoffice", obj.getString("wboxoffice"));

map.put("tboxoffice", obj.getString("tboxoffice"));

list.add(map);

}

} catch (JSONException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return list;

}


你可能感兴趣的:(json字符串解析)