如何操作这段json:
{
"id": "whatever",
"attributes": [
{
"key": "this",
"value": "A"
},
{
"key": "that",
"value": "B"
},
{
"key": "other",
"value": "C"
}
]
}
以便与"并删除分组中的键和值,留下这样的json:
{
"id": "whatever",
"attributes": [
{
"key": "this",
"value": "A"
},
{
"key": "other",
"value": "C"
}
]
}
我正在尝试在linux上使用jq .
试试这个
.attributes |= map(select(.key != "that"))
演示我明白了
jq 'del(.attributes[] | select(.key == "that"))' test.json | sponge test.json