greycat 1519238863 learn To create JSON strings with variable assignments: jq -nc --arg bar "$bar" '{foo:$bar}' ;# compare with awk -v awkvar="$bashvar" tirnanog 1644638075 forget tirnanog 1644638102 learn To create JSON strings with variable assignments: jq -nc --arg bar "$bar" '{foo:$bar}'. This approach is comparable to awk -v awkvar="$bashvar". Alternatively: printf '{foo:%s}' "$(jshon -Qs "$bar")". See !inject for other topics concerning the avoidance of code injection.