【发布时间】:2023-03-17 13:31:01
【问题描述】:
这是我的 JSON 数据输入:
[
{
"creator": "M.W. Seo",
"co_author": [
"H.W. Lee",
"S.H. Jeon",
"M.W. Seo"
]
},
{
"creator": "Jeffrey A. Laman",
"co_author": [
"Jeffrey A. Laman",
"Mike",
"Jackson"
]
}
]
这是我想要的 JSON 数据输出:
[
{
"creator": "M.W. Seo",
"co_author": [
"H.W. Lee",
"S.H. Jeon"
]
},
{
"creator": "Jeffrey A. Laman",
"co_author": [
"Mike",
"Jackson"
]
}
]
我尝试过但不起作用的方法:
jq '.[:2]| map(if .co_author[] == .creator then del(.co_author[])' test_4.json
【问题讨论】: