public void testJson() {
JSONObject object = new JSONObject();
//string
object.put(“string”,“string”);
//int
object.put(“int”,2);
//boolean
object.put(“boolean”,true);
//array
List integers = Arrays.asList(1,2,3);
object.put(“list”,integers);
//null
object.put(“null”,null);
System.out.println(object);
}
JSON.parseObject() 从字符串解析 JSON 对象
JSON.parseArray() 从字符串解析 JSON 数组
JSON.toJSONString(obj/array) 将 JSON 对象或 JSON 数组转化为字符串