I work with Json looks something like below
[
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "everyone",
"permission": "Allow"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$owner",
"permission": "ALLOW"
}
]
I would like to change the access type to "restricted" instead of "*" for the PrincipalID: "everyone"...
I am using something like sed '\{[^}]*?everyone[^}]*\},s,"accessType": "*","accessType": "Restricted",' sdcard/etc/sample.json but it doesnt work. it has to look like below:
{
"accessType": "Restricted",
"principalType": "ROLE",
"principalId": "everyone",
"permission": "Allow"
},
it is a continuation to the previous question: Regex to match specific, multiline object in JSON list
I cannot use any 3rd party applications to perform this action, only using sed and regex or any 1 liner unix command