我有一个这样的json文件:
{
"id": 123,
"guid": "XXXX",
"isEnabled": true,
"createdBy": "Admin",
"updatedBy": "XXXXX",
"createTime": 987654321,
"updateTime": 79456123,
"version": 1,
"service": "XXXXX",
"name": "all - consumergroup",
"policyType": 0,
"policyPriority": 0,
"description": "Policy for all - consumergroup",
"resourceSignature": "XXXXXXXXXX",
"isAuditEnabled": true,
"resources": {
"consumergroup": {
"values": [
"*"
],
"isExcludes": false,
"isRecursive": false
}
},
"policyItems": [
{
"accesses": [
{
"type": "consume",
"isAllowed": true
},
{
"type": "describe",
"isAllowed": true
}
],
"users": [
"XXXX",
"XXXXX",
"XXXX",
"XXXXXX",
"XXXXX",
"XXXXXX",
"XXXXXX",
"usrpfm"
],
"groups": [
""
],
"roles": [],
"conditions": [],
"delegateAdmin": false
},
{
"accesses": [
{
"type": "consume",
"isAllowed": true
},
{
"type": "describe",
"isAllowed": true
},
{
"type": "delete",
"isAllowed": true
}
],
"users": [
"rangerlookup"
],
"groups": [
""
],
"roles": [],
"conditions": [],
"delegateAdmin": false
}
],
"denyPolicyItems": [],
"allowExceptions": [],
"denyExceptions": [],
"dataMaskPolicyItems": [],
"rowFilterPolicyItems": [],
"serviceType": "kafka",
"options": {},
"validitySchedules": [],
"policyLabels": [],
"zoneName": "",
"isDenyAllElse": false
}
如何在Bash上添加用户(可能使用jq
命令)(例如:BATU)和阵列用户
"users":["XXXX","XXXXX",...,"XXXXXX","usrpfm"]
转向
"users":["XXXX","XXXXX",...,"XXXXXX","usrpfm","BATU"]
这个JSON
1条答案
按热度按时间jgovgodb1#
尝试以下操作:
使用“|= . +”向policyItems[0].users添加额外的数组索引(BATUU)