List<Map<String,Object>> to org.json.JSONObject?
问题 List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); map.put("abc", "123456"); map.put("def", "hmm"); list.add(map); JSONObject json = new JSONObject(list); try { System.err.println(json.toString(2)); } catch (JSONException e) { e.printStackTrace(); } What's wrong with this code? The output is: {"empty": false} 回答1: public String listmap_to_json_string(List<Map<String, Object>> list) { JSONArray json_arr=new JSONArray(