我如何操作這塊 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。
uj5u.com熱心網友回復:
嘗試這個
.attributes |= map(select(.key != "that"))
演示
uj5u.com熱心網友回復:
弄清楚了。
jq 'del(.attributes[] | select(.key == "that"))' test.json | 海綿測驗.json
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/325938.html
