判断json对象的属性的值是json对象还是json数组
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json

·
1.json对象的属性的值是json对象,结构如下:
info属性为json对象
{
"name":"zhangsan",
"age":14,
"info":{
“address”:"bejing",
“school”:“北京一中”,
“class”:"六年级"
}
}
2.json对象的属性的值是json数组,结构如下:
info属性为json数组
{
"name":"zhangsan",
"age":14,
"info":[
{
“address”:"bejing",
“school”:“北京一中”,
“class”:"六年级"
},
{
“address”:"bejing",
“school”:“北京二中”,
“class”:"五年级"
},
{
“address”:"bejing",
“school”:“北京三中”,
“class”:"四年级"
}
]
}
3.判断json对象的属性的值是json对象还是json数组
判断info的值是json对象还是json数组,使用fastjson API
if (paramObj.getString("info").startsWith("["))
{
//属性值是json数组
JSONArray jsonArray = JSONArray.fromObject(paramObj.get("attr"));
}
else if (paramObj.getString("info").startsWith("{"))
{
//属性值是json对象
JSONObject jsonObject = JSONObject.fromObject(paramObj.get("attr"));
}




适用于现代 C++ 的 JSON。
最近提交(Master分支:17 天前 )
230bfd15
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.6.0 to 4.7.0.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](https://github.com/actions/dependency-review-action/compare/ce3cf9537a52e8119d91fd484ab5b8a807627bf8...38ecb5b593bf0eb19e335c03f97670f792489a8b)
---
updated-dependencies:
- dependency-name: actions/dependency-review-action
dependency-version: 4.7.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 5 天前
e9391dc5
Bumps [lukka/get-cmake](https://github.com/lukka/get-cmake) from 4.0.1 to 4.02.
- [Release notes](https://github.com/lukka/get-cmake/releases)
- [Commits](https://github.com/lukka/get-cmake/compare/57c20a23a6cac5b90f31864439996e5b206df9dc...ea004816823209b8d1211e47b216185caee12cc5)
---
updated-dependencies:
- dependency-name: lukka/get-cmake
dependency-version: '4.02'
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 7 天前
更多推荐
所有评论(0)