[英]Jayway JsonPath Filter expression for inner array
I have a JSON file in the format below.我有一个格式如下的 JSON 文件。
{
"queryResponse":[
{
"id":"1",
"name":"Parent1",
"childList":[
{
"id":"11",
"type":"A"
},
{
"id":"12",
"type":"B"
}
]
},
{
"id":"2",
"name":"Parent2",
"childList":[
{
"id":"21",
"type":"B"
},
{
"id":"22",
"type":"C"
}
]
}
]
}
Using jayway JsonPath, how do I get all the Parent nodes which have child nodes with type "B"?使用 jayway JsonPath,如何获取所有具有“B”类型子节点的父节点?
These filter expressions returned an empty array:这些过滤器表达式返回一个空数组:
The only filter expression that is closest to what I want is the one with array index for ex: $.queryResponse[?(@.childList[0].type=='A')]唯一最接近我想要的过滤器表达式是带有数组索引的表达式: $.queryResponse[?(@.childList[0].type=='A')]
Use contains
or in
operator使用contains
或in
运算符
$.queryResponse[?(@.childList[*].type contains 'B')]
OR或者
$.queryResponse[?('B' in @.childList[*].type )]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.