Reputation: 1418
I'm trying to follow this: https://jqlang.org/manual/#string-interpolation
In powershell I try this:
echo '{"key": "value"}' | jq '\"Theinputwas:\(.key)\"'
And get this: "Theinputwas:value"
But, if I try to add whitespaces in the string: echo '{"key": "value"}' | jq '\"The input was:\(.key)\"'
I get: jq: error: syntax error, unexpected end of file, expecting QQSTRING_TEXT or QQSTRING_INTERP_START or QQSTRING_END (Windows cmd shell quoting issues?)
I spent a lot of time to finally make the interpolation work on powershell because of the multiple quotes, but now I'm stuck with this whitespace problem that is not mentioned by jq.
Upvotes: 0
Views: 32
Reputation: 36336
this whitespace problem that is not mentioned by jq
This is not a problem with jq on Linux, so I guess it has to do with the different quoting/escaping rules in Windows/PowerShell. Apparently, adding a space character either after the opening or before the closing code quote seems to work (with jq 1.7.1 in PS 5.1 on Win 10):
echo '{"key": "value"}' | jq ' \"The input was:\(.key)\"'
# space added here -----------^ or here -----------v
echo '{"key": "value"}' | jq '\"The input was:\(.key)\" '
"The input was:value"
Upvotes: 0