python - 有没有办法找到密钥是否存在 jsonpath-ng
问题描述
例如 :
client_json = {
"data": [
{
"attributes": {
"creators": [
{
"name": "This is a person",
"nameType": "Personal",
"givenName": "the",
"familyName": "person"
},
{
"name": "This is an organization",
"nameType": "Organizational",
"givenName": "the",
"familyName": "organization"
}
]
}
}
]
}
在上面的 json 中,我想检查这个 json 路径是否存在键,$.[0].attributes.creators[0].name,
我不担心值。
我可以这样做jsonpath-ng
吗?我以前使用jsonpath
过 Stefan Goessner 的图书馆,但现在已经过时了。
我想要python中与此类似但确实存在()的东西
解决方案
据我所知,您不必使用任何类型的库来进行查找。由于 Python 像字典一样处理 JSON。这是我会尝试的:
for key in client_json.items():
print key
推荐阅读
- flutter - 如何在行中固定位置子小部件?扑
- html - 我如何将我的 svg 在视口中间的 css 中居中?
- python - 为什么主循环停止后程序没有停止?
- python - 如何从 .txt 文件中读取 URL 以执行 requests.get 并将响应保存到文件中?
- go - 如何将 Kubernetes 操作员错误传播到 kubectl 命令行?
- mysql - 如何从昏暗的表中创建 pentaho 中的事实表?
- arrays - 如何在 PostgreSQL 中的数组上添加外键约束?
- python - 如何在网站上使用 python matplotlib 代码?
- sql-server - 选择连接表上的最近日期
- android - 如何使用活动擦除 Android 循环中的历史记录?