【发布时间】:2017-07-23 09:45:20
【问题描述】:
我有一个json作为
[
{
"id":1,
"author": "hippy",
"reviewers": [
{
"name": "hippy",
"status": "ok"
},
{
"name": "other",
"status": "ok"
}
]
},
{
"id":2,
"author": "hippy",
"reviewers": [
{
"name": "hippy",
"status": "ok"
},
{
"name": "build",
"status": "ok"
}
]
},
{
"id":3,
"author": "hippy",
"reviewers": [
{
"name": "hippy",
"status": "ok"
}
]
},
{
"id":4,
"author": "other",
"reviewers": [
{
"name": "hippy",
"status": "ok"
}
]
}
]
我想在排除审阅者build后得到reviewer与author相同的项目。
即我想用ids 2, 3 获取项目。
我能做到这么远
.[]
| select(
.author as $author
| {reviewers}
| .[]
| map(.name)
| select(.[] == $author)
)
但是带有id 1 的项目是误报,我也想过滤掉它。
【问题讨论】: