import json
body={'discountPrice':{'1':'5.4847','59':'5.1938','100':'4.9030'}}

 #将dict类型的数据转换成str
jsDumps=json.dumps(body)
jsLoads = json.loads(jsDumps)
if ('discountPrice' in jsLoads) :
    print('存在')
else:
    print('不存在')


#循环获取key和value
for r in jsLoads['discountPrice']:
    print(f'qty:{r} price{jsLoads["discountPrice"][r]}')

GitHub 加速计划 / js / json
57
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
68c25aec * :memo: update customers Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :memo: add badge to Cloudback Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> 4 天前
ac0133ea Bumps [mkdocs-git-revision-date-localized-plugin](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin) from 1.4.5 to 1.4.6. - [Release notes](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/releases) - [Commits](https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/compare/v1.4.5...v1.4.6) --- updated-dependencies: - dependency-name: mkdocs-git-revision-date-localized-plugin dependency-version: 1.4.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 5 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐