> It's about sanitized inputs.
Less sanitized and more correctly formatted. Writing literal JSON by hand at the CLI is not fun.
Less sanitized and more correctly formatted. Writing literal JSON by hand at the CLI is not fun.
data=$(jq -n \
--arg title 'what"ever' \
--arg endpoint 'foo"bar' \
'{
"title": $title,
"endpoint": $endpoint,
"enabled": true
}') $ my_json="$(cat <<EOF
> {
> "foo": "bar",
> "baz": 42
> }
> EOF
> )"
$ echo "$my_json"
{
"foo": "bar",
"baz": 42
}
But I definitely didn't remember how to handle the closing paren and closing quote correctly, and I had to google for an example just now. So I'm not allowed to say this is easy to remember :) foo="$(cat <<EOF)"
whatever
EOF
This is left undefined in the POSIX standard and bourne shells don't allow it.