Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--argjson not supported #180

Open
bb1 opened this issue May 7, 2024 · 5 comments
Open

--argjson not supported #180

bb1 opened this issue May 7, 2024 · 5 comments
Labels
good first issue Good for newcomers

Comments

@bb1
Copy link

bb1 commented May 7, 2024

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! :)

@01mf02
Copy link
Owner

01mf02 commented May 7, 2024

This would probably make a nice first issue if someone wants to work on this. :)

@01mf02
Copy link
Owner

01mf02 commented May 7, 2024

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.

@01mf02
Copy link
Owner

01mf02 commented May 7, 2024

In the meanwhile, @bb1, you can use --arg a v and then use $a | fromjson instead of $a.

@01mf02 01mf02 added the good first issue Good for newcomers label May 7, 2024
@bb1
Copy link
Author

bb1 commented May 7, 2024

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.

@wader
Copy link
Contributor

wader commented May 7, 2024

@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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants