【发布时间】:2020-08-20 08:37:47
【问题描述】:
我正在创建示例 JSON,如下所示。我想通过在特定条件下使用来检索价值。
观察下面的语句:
'$.Attributes..Attribute[?(@.setcode=="x")]'
但我无法使用代码检索该值。
"{
"Attributes": [
{
"Attribute": {
"setcode": "x",
"codeType": "movieType",
"AttributeGroup": [
{
"code": "Force",
"codeValueValue": "'I'"
},
{
"code": "Remain",
"codeValueValue": "'P'"
},
{
"code": "Died",
"codeValueValue": "'E'"
},
{
"code": "Renew",
"codeValueValue": "'R'"
}
]
}
},
{
"Attribute":{
"setcode": "y",
"codeType": "movietype",
"AttributeGroup": [
{
"code": "Force",
"codeValueValue": "'I'"
},
{
"code": "Remain",
"codeValueValue": "'P'"
},
{
"code": "Died",
"codeValueValue": "'E'"
},
{
"code": "Renew",
"codeValueValue": "'R'"
}
]
}
}
]
}"
【问题讨论】:
-
欢迎来到 Stack Overflow。为了获得对您的问题有用的答案,发布带有代码的最少可重现示例,并明确说明您的期望以及发生的事情与您的期望有何不同(包括任何错误消息)会很有帮助。此外,如果您遇到涉及
parse error near token ?的错误,请查看此 Github 问题:github.com/h2non/jsonpath-ng/issues/16
标签: python jsonpath-ng