As the error message suggests, put parentheses around the key:
jq -r --arg k "foo" --arg v "bar" '.newField += {($k):$v}' myfile
jq requires keys given by expressions (i.e. not literal strings) to be parenthesized (noted in the manual).
As the error message suggests, put parentheses around the key:
jq -r --arg k "foo" --arg v "bar" '.newField += {($k):$v}' myfile
jq requires keys given by expressions (i.e. not literal strings) to be parenthesized (noted in the manual).