FastJson是阿里巴巴开源的Java对象和JSON格式字符串的快速转换的工具库,和google的Gson用法相似
● 将对象转换为JSON字符串
转换JSON字符串的步骤:
1. 引入JAR包
2. 在需要转换JSON字符串的位置编写如下代码即可:String json=JSON.toJSONString(要转换的对象);
● 将JSON字符串转换为对象
1. 引入JAR包
2. 在需要转换Java对象的位置, 编写如下代码:类型 对象名=JSON.parseObject(JSON字符串, 类型.class);或List<类型> list=JSON.parseArray(JSON字符串,类型.class);
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台用户上传并发布,不构成投资建议请自行甄别,如有侵权请联系删除:liaycn@163.com
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of the site, which is a social media platform and only provides information storage services.