当前位置:网站首页>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();
}
}
边栏推荐
猜你喜欢
一体化伺服电机在三轴钻孔机中的应用
干货!迈向鲁棒的测试时间适应
如何正则匹配乱码?
Live Preview | ICML 2022 11 first-author scholars share online neural network, graph learning and other cutting-edge research
位图的基本原理以及应用
技术盛宴!华云数据携六大议题亮相OpenInfra Days China
Travel with Shengteng: See all the AI attractions in Jinling City in one day
【Burning】It's time to show your true strength!Understand the technical highlights of the 2022 Huawei Developer Competition in one article
全面解析FPGA基础知识
离散选择模型之Gumbel分布
随机推荐
2021年国内外五大BI厂商——优秀的商业智能工具推荐
2020年度SaaS TOP100企业名单
多商户商城系统功能拆解24讲-平台端分销会员
什么是平面文件数据库? 如何导入多种格式的文件:DSV、JSON、XML?
【接口测试】requests 库请求体字符串解码
测试2年,当时身边一起入行的朋友已经月薪20k了,自己还没过万,到底差在了哪里?
34. Fabric2.2 证书目录里各文件作用
【云原生】一文讲透Kubevela addon如何添加腾讯Crane
Mysql/stonedb - slow SQL - 2022-08-09 Q16 analysis
Qt 之 QDateEdit 和 QTimeEdit
直播app开发搭建,flutter 实现自适应、自动换行、相对布局
tiup cluster scale-out
Filament - Material basic graphics drawing
Comprehensive analysis of FPGA basics
用函数统计最长单词的字母数量
Leetcode 98. 验证二叉搜索树
VR全景结合小程序,为线上电商更好的服务
金仓数据库 KingbaseGIS 使用手册(6.4. 几何对象存取函数)
【JZOF】77按之字形打印二叉树
直播间搭建,按钮左滑出现删除等操作按钮