In a very simplified senes, I would like to take an existing JSON object and use jq
to add/update two additional values to it. For example
Start | Result |
---|---|
{} | {"a": 1, "b":2} |
{"a":42} | {"a": 1, "b":2} |
{"a":"hello"} | {"a": 1, "b":2} |
{"b":"qwerty"} | {"a": 1, "b":2} |
I can set either a
or b
with two back to back commands like so echo {} | jq '.a=1' | jq '.b=2'
. But I was wondering if there is a way to make only a single jq
call to do both operations?