对于给定的 json:
{
"source_1": [
{
"val1": "foo1",
"val2": "bar1"
},
{
"val1": "foo2",
"val2": "bar2"
}
],
"source_2": [
{
"val1": "foo1",
"val2": "bar1"
},
{
"val1": "foo3",
"val2": "bar3"
}
]
}
我想在
val2
== bar1
处递归搜索它,但以这种格式返回它:
{
"source_1": [
{
"val1": "foo1",
"val2": "bar1"
}
],
"source_2": [
{
"val1": "foo1",
"val2": "bar1"
}
]
}
这会产生您预期的输出:
map_values(map(select(.val2 == "bar1")))