1,内容是字符串
String json = JSON. toJSONString(list);
结果:["111" ,"222"]
2,内容是时间
SerializeConfig config = new SerializeConfig();
config. put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd HH:mm:ss"));
String json = JSON. toJSONString(list, config);
System. out. println(json);
结果:["2022-11-05 11:23:22" ," 2022-11-05 11 :23:22"]
3,内容是对象
List students = new ArrayList<>();
String json = JSON.toJSONString(students);
结果:【{111},{222}】