Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 527

jq to set several explicit properties at once

$
0
0

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

StartResult
{}{"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?


Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>