This is VERY similar to Update one value in array of dicts, using jq
I have a foo.json and I want to update AAA to AAA-MY-SUFFIX. Basically, I want to get the current value (AAA), and then add a suffix to it.
[
{
"Key": "Name",
"Value": "awesome"
},
{
"Key": "role",
"Value": "AAA"
}
]
From the previous question, I can REPLACE the value of AAA using this:
cat foo.json | jq '(.[] | select(.Key == "role") | .Value) |= "-MY_SUFFIX"'
But I want to APPEND a suffix to the existing value, not completely replace it.
Something like this (but it doesn't work, of course):
cat tags.json | jq '(.[] | select(.Key == "role") | .Value) |= .Value + "-MY_SUFFIX"'
I feel I'm SO close, but I just can figure it out :(