Skip to content

Instantly share code, notes, and snippets.

View guillim's full-sized avatar

Guillim guillim

View GitHub Profile
@guillim
guillim / jq-insert-var.sh
Created June 11, 2018 11:52 — forked from joar/jq-insert-var.sh
Add a field to an object with JQ
# Add field
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}'
# {
# "hello": "world",
# "foo": "bar"
# }
# Override field value
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}'
{