I have a large json that looks similar to this
{
"Report" : [
{"blah" : "..."}
],
"Actions" : [
{
"value" : "1",
"properties" : {
"name" : "abc",
"age" : "2",
"other": "test1"
}
},
{
"value" : "2",
"properties" : {
"name" : "def",
"age" : "3",
"other" : "test2"
}
}
]
}
and I need to change the value of "other" depending on the value of "age".
Now, I want the complete json to be output on the terminal, so I can move it to tmp file.
This command works but outputs only the Action block on the terminal
jq '(.Actions[] | select (.properties.age == "3").properties.other = "no-test")'
This command prints the complete json, but rewrites the value for keys that should not be modified (notice "no-test" gets re-written for both ages 2 and 3).
jq '(. | select (.Actions[].properties.age == "3").Actions[].properties.other = "no-test")'
Please advise if there is a way to zone in on the block to the changed, yet output the complete json on the terminal.