简体   繁体   English

具有嵌套数组的对象数组的Jsonpath

[英]Jsonpath for array of objects with nested arrays

I am trying to write a jsonpath for following object: 我正在尝试为以下对象编写jsonpath:

{
    "ParentArray": [
        {
            "ChildArray": [
                {
                    "ChildArrayObjectKey": "ChildArrayObjectValue1"
                },
                {
                    "ChildArrayObjectKey": "ChildArrayObjectValue2"
                }
            ]    
        },
        {
             "ChildArray": [
                {
                    "ChildArrayObjectKey": "ChildArrayObjectValue3"
                },
                {
                    "ChildArrayObjectKey": "ChildArrayObjectValue4"
                }
            ]  
        }  
    ]
}

Which would extract the object from the ParentArray. 哪个会从ParentArray中提取对象。 I am looking for an object which contains a value 'ChildArrayObjectValue3' in its ChildArray. 我正在寻找一个在其ChildArray中包含值'ChildArrayObjectValue3'的对象。 The solution I think should work is: 我认为应该解决的解决方案是:

$.ParentArray[?(@.ChildArray[?(@.ChildArrayObjectKey === 'ChildArrayObjectValue3')])]

But unfortunately it does not provide any results. 但不幸的是,它没有提供任何结果。 What I would like to extract is: 我想提取的是:

{
    "ChildArray": [
        {
            "ChildArrayObjectKey": "ChildArrayObjectValue3"
        },
        {
            "ChildArrayObjectKey": "ChildArrayObjectValue4"
        }
    ]  
}

试试这种方式:$ .ParentArray .. * [?(@。ChildArrayObjectKey =='ChildArrayObjectValue3')]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM