I have the given JSON and want to change the id value of all elements, which starts with test in the name element:
id
test
name
{
You can also use map, like this:
map
jq '(.values)|=(map((if .name|startswith("test") then .id="NEWID" else . end)))' file
Output:
{ "other-value": "some-id", "values": [ { "name": "test-2017-12-01", "id": "NEWID" }, { "name": "othert", "id": "2" } ] }