Closed timfallmk closed 4 years ago
Interesting…
The goal of this function (toJsonOrNull
) is to always return a valid JSON object (which is either verbosely double-quoted, or a null
).
Your change would effectively turn this:
jq -nc --argjson key '"value"' '{$key}'
into this:
jq -nc --argjson key "'value'" '{$key}'
jq: invalid JSON text passed to --argjson
Use jq --help for help with command-line options,
or see the jq manpage, or online docs at https://stedolan.github.io/jq
Not quite certain how/why your proposed change works - need to look more into it 🤔.
I wasn’t aware it required double quoted strings, that’s interesting.
There must be a way of passing the string as a literal to avoid interpolation. Perhaps using literal single quotes in the output from the previous step would help.
-Tim On Dec 6, 2019, 19:17 -0800, Damian Mee notifications@github.com, wrote:
Interesting… The goal of this function (toJsonOrNull) is to always return a valid JSON object (which is either verbosely double-quoted, or a null). Your change would effectively turn this: jq -nc --argjson key "'value'" '{$key}' into this: jq -nc --argjson key '"value"' '{$key}' — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I’m going to close this until there’s a solution that works in more cases!
We probably want to return a single quoted string here so any contents is treated as a literal instead of being interpolated.
Fixes #10
Note: I've only tested this for my use case, so any other testing would be appreciated!