Using jq I want to update a value in a json object.The key of the value to be updated is passed as an argument.
Input
{"a": 1,"b": 2,"c": 3}Expected output with argument: key=b
{"a": 1,"b": 42,"c": 3}I tried to do:
jq --arg key b '.($key) |= . + 40'jq --arg key b '".\($key)" |= . + 40'Both attempts result in errors:
syntax error, unexpected '('Invalid path expression with result ".b"
How can I solve this problem?