我有一个json文件example.json
[
{
"node": "cp-phix-app-uat14.hcinternal.net:80",
"priority": 1,
"state": "draining",
"weight": 1
},
{
"node": "cp-phix-app-uat13.hcinternal.net:80",
"priority": 1,
"state": "active",
"weight": 1
}
]
我想使用jq进行查询,如果我的节点键是" cp-phix-app-uat14.hcinternal.net:80"然后把状态作为"活跃的'所以我的输出应该是: -
[
{
"node": "cp-phix-app-uat14.hcinternal.net:80",
"priority": 1,
**"state": "active",**
"weight": 1
},
{
"node": "cp-phix-app-uat13.hcinternal.net:80",
"priority": 1,
"state": "active",
"weight": 1
}
]
我可以做什么查询..我正在使用linux ubuntu机器。
答案 0 :(得分:0)
map( if .node == "cp-phix-app-uat14.hcinternal.net:80"
then .state = "active"
else .
end )