我有一个带有如下所示块的JSON文件
{
"id": 0000,
"sGName": "SG1",
"customProperties": [
{
"id": 100000,
"name": "clustersIP",
"value": "ABC"
}
],
"filters": [
{
"id": 74616,
"attributeName": "serverName",
"value": "Sever101"
},
{
"id": 74617,
"attributeName": "bigIPPool",
"value": "server101v1"
}
],
},
我正在寻找bash中的JQ来检索sGName,其中“ attributeName” =“服务器名”和“ value” =“ Sever101”可以有人帮忙吗?
我可能有多个“ sGName”
我相信您正在寻找以下命令:
jq --raw-output 'map( select(.filters | map(select(.attributeName == "serverName")) | length > 0) |.sGName) | join("\n")'
您可以try it here。