Need some help for change the value in JSON file using jq command.
Error:
[jenkins@devops-dev-02 New]$ jq 'map(if .Tags[11].Key == "Period" then .Tags[11].Value = "Weekly" else . end)' create_snapshot.json
jq: error (at create_snapshot.json:54): Cannot index string with string "Tags"
[jenkins@devops-dev-02 New]$
JSON File:
{
"DBSnapshotIdentifier":"snapshot-myrds-backup-1",
"DBInstanceIdentifier":"myrds",
"Tags":[
{
"Key":"Name",
"Value":"snapshot-myrds-backup-1"
},
{
"Key":"Application",
"Value":"myapp"
},
{
"Key":"Environment",
"Value":"Dev and QA"
},
{
"Key":"Period",
"Value":"Daily"
}
]
}
map()doesn't make sense as the top-level call when your only item is a dict.