赞
踩
一、解析json字符串
json字符串如下:
{
content: [{
"name": "当地时间",
"value": "",
"key": "1657176228000_40613",
"type": "date",
"typeTwo": "datetime",
"options": []
}, {
"name": "业务UUID",
"value": "",
"key": "1657176314000_84880",
"type": "input",
"typeTwo": null,
"options": []
}, ]
message: success
}
解析代码:
// 字符串转换为json对象
JSONObject arr = JSONObject.parseObject(jsonValue);
// 获取第一层message值
arr.getString("message");
//获取对象名为content的数组
JSONArray arrq = arr.getJSONArray("content");
//获取数组下标索引值为0时,key为name的值
arrq .getJSONObject(0).getString("name");
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。