fastjson list转json

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}】

相关推荐
消失的旧时光-194312 小时前
Kotlinx.serialization 使用指南
android·kotlin·json
消失的旧时光-194313 小时前
Kotlinx.serialization 项目集成
android·kotlin·json
坚持就完事了1 天前
JSON的了解
json
奥吼吼~~1 天前
标准输入输出stdio和JSON-RPC
网络协议·rpc·json
littlepeanut.top2 天前
C++中将FlatBuffers序列化为JSON
开发语言·c++·json·flatbuffers
遇见火星2 天前
LINUX的 jq命令行处理json字段指南
java·linux·json·jq
凌波粒3 天前
SpringMVC基础教程(2)--Controller/RestFul风格/JSON/数据转发和重定向
java·后端·spring·json·restful
羊锦磊4 天前
[ 项目开发 1.0 ] 新闻网站的开发流程和注意事项
java·数据库·spring boot·redis·spring·oracle·json
码上淘金4 天前
在 YAML 中如何将 JSON 对象作为字符串整体赋值?——兼谈 Go Template 中的 fromJson 使用
java·golang·json