当前位置:网站首页>JSON对象和字符串相互转化
JSON对象和字符串相互转化
2022-08-09 22:33:00 【爱码~】
- fastjson
/** JSON对象和字符串相互转化 * */
public class JsonTest {
public static void main(String[] args) {
String datauin = "{\"stepInfoList\":[{\"timestamp\":1656777600,\"step\":8061},{\"timestamp\":1656864000,\"step\":9729},{\"timestamp\":1656950400,\"step\":7707},{\"timestamp\":1657036800,\"step\":10395},{\"timestamp\":1657123200,\"step\":12105},{\"timestamp\":1657209600,\"step\":10122},{\"timestamp\":1657296000,\"step\":5429},{\"timestamp\":1657382400,\"step\":7787},{\"timestamp\":1657468800,\"step\":9280},{\"timestamp\":1657555200,\"step\":14718},{\"timestamp\":1657641600,\"step\":11521},{\"timestamp\":1657728000,\"step\":9522},{\"timestamp\":1657814400,\"step\":11351},{\"timestamp\":1657900800,\"step\":4744},{\"timestamp\":1657987200,\"step\":14134},{\"timestamp\":1658073600,\"step\":13120},{\"timestamp\":1658160000,\"step\":10435},{\"timestamp\":1658246400,\"step\":9260},{\"timestamp\":1658332800,\"step\":11384},{\"timestamp\":1658419200,\"step\":7020},{\"timestamp\":1658505600,\"step\":7544},{\"timestamp\":1658592000,\"step\":14012},{\"timestamp\":1658678400,\"step\":10117},{\"timestamp\":1658764800,\"step\":12207},{\"timestamp\":1658851200,\"step\":9484},{\"timestamp\":1658937600,\"step\":8209},{\"timestamp\":1659024000,\"step\":12646},{\"timestamp\":1659110400,\"step\":8928},{\"timestamp\":1659196800,\"step\":5946},{\"timestamp\":1659283200,\"step\":8288},{\"timestamp\":1659369600,\"step\":5421}],\"watermark\":{\"timestamp\":1659440140,\"appid\":\"wx66314a80dc7d2c46\"}}\n";
// 将字符串转化成json对象
JSONObject jsonObject = JSONObject.parseObject(datauin);
jsonObject.put("key","value");
String value = jsonObject.getString("key");
// json对象转成字符串
String s = jsonObject.toString();
}
}
边栏推荐
- torch.distributed多卡/多GPU/分布式DPP(二)——torch.distributed.all_reduce(reduce_mean)&barrier&控制进程执行顺序&随机数种子
- 6款跨境电商常用工具汇总
- ABAP中Collect的用法
- 什么是平面文件数据库? 如何导入多种格式的文件:DSV、JSON、XML?
- Day 12 of learning to program
- Controller层代码这么写,简洁又优雅!
- Qt 之 QDateEdit 和 QTimeEdit
- Sqlserver restricts the ip under which accounts can access the database
- SRv6性能测量
- JS--hashchange事件--使用/教程
猜你喜欢
随机推荐
位图的基本原理以及应用
干货!迈向鲁棒的测试时间适应
【励志】名言警句
力扣:322. 零钱兑换
VR全景拍摄如何拍摄?如何使用拍摄器材?
shader学习笔记(五)
Has your phone ever been monitored?
【诗歌】最高级的惩罚就是沉默
【接口测试】requests 库请求体字符串解码
Snap: 322. Change of Change
32 JZOF 】 【 print down on binary tree
34. Fabric2.2 证书目录里各文件作用
Day 12 of learning to program
你的手机曾经被监控过吗?
What are the basic steps to develop a quantitative trading strategy?
Leetcode 701. 二叉搜索树中的插入操作
【对象——对象及原型链上的属性——对象的操作方法】
Mysql集群 ShardingSphere
tiup cluster start
tiup cluster template