Answer the question
In order to leave comments, you need to log in
How to use jq to add a value from a variable containing spaces?
json="{}"
foo="Without_spaces"
bar="With spaces"
json=$(jq '.one = "Without_spaces"' <<< $json)
json=$(jq '.two = "With spaces"' <<< $json)
json=$(jq '.foo = "'$foo'"' <<< $json)
# json=$(jq '.bar = "'$bar'"' <<< $json)
jq . <<< $json
jq: error: syntax error, unexpected $end, expecting QQSTRING_TEXT or QQSTRING_INTERP_START or QQSTRING_END (Unix shell quoting issues?) at <top-level>, line 1:
.bar = "With
jq: 1 compile error
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question