Open bb1 opened 2 months ago
This would probably make a nice first issue if someone wants to work on this. :)
Note that --argjson a '[1, 2, 3]
binds $a
to [1, 2, 3]
, yet:
$ jq --argjson a '1 2 3' -n '$a'
jq: invalid JSON text passed to --argjson
So --argjson
only considers a single JSON value, like fromjson
.
In the meanwhile, @bb1, you can use --arg a v
and then use $a | fromjson
instead of $a
.
I added a link to the test-case for this parameter in the original jq. But I'm still not quiet sure that I understand the difference. BTW: maybe adding these test-cases would increase the compatibility even more.
@bb1 difference using --arg
workaround? you can do something like:
# parse and shadow $a binding with a new $a
$ jaq -nc --arg a '[1,2,3]' '($a | fromjson) as $a | $a'
[1,2,3]
# works same as
$ jq -nc --argjson a '[1,2,3]' '$a'
[1,2,3]
This is useful when working with lists. Here is a test from the original jq: https://github.com/jqlang/jq/blob/c1276169d658783924add7ff72bb2e2d07b04141/tests/shtest#L289
Also great tool! Thanks for creating it! :)