java-将列表格式化成json字符串
List<String> list = new ArrayList<>(); list.add("{'county':'china','age':18}"); list.add("{'county':'japan','age':28}"); String data = JSON.toJSONString(list,SerializerFeature.WriteNullListAsEmpty); System.out.println(data);
结果:
"[\"{'county':'china','age':18}\",\"{'county':'japan','age':28}\"]"