1.
JSONObject jsonObject = new JSONObject(); jsonObject.put("a", "1"); jsonObject.put("b", "2"); jsonObject.put("c", "3"); System.out.println(jsonObject);
{"a":"1","b":"2","c":"3"}
2.
Map<String, String> map = new HashMap<String, String>(); map.put("a","1"); map.put("b","2"); map.put("c","3"); System.out.println(JSONObject.fromObject(map));
{"b":"2","c":"3","a":"1"}
时间: 2024-10-17 13:30:40