我正在尝试为以下对象编写jsonpath:
{
"ParentArray": [
{
"ChildArray": [
{
"ChildArrayObjectKey": "ChildArrayObjectValue1"
},
{
"ChildArrayObjectKey": "ChildArrayObjectValue2"
}
]
},
{
"ChildArray": [
{
"ChildArrayObjectKey": "ChildArrayObjectValue3"
},
{
"ChildArrayObjectKey": "ChildArrayObjectValue4"
}
]
}
]
}
哪个会从ParentArray中提取对象。我正在寻找一个在其ChildArray中包含值'ChildArrayObjectValue3'的对象。我认为应该解决的解决方案是:
$.ParentArray[?(@.ChildArray[?(@.ChildArrayObjectKey === 'ChildArrayObjectValue3')])]
但不幸的是它没有提供任何结果。我想提取的是:
{
"ChildArray": [
{
"ChildArrayObjectKey": "ChildArrayObjectValue3"
},
{
"ChildArrayObjectKey": "ChildArrayObjectValue4"
}
]
}
答案 0 :(得分:0)
尝试这种方式:$ .ParentArray .. * [?(@。ChildArrayObjectKey =='ChildArrayObjectValue3')]