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

missing filters: $__loc__, input_filename, input_line_number #90

Closed
pkoppstein opened this issue Jul 13, 2021 · 5 comments
Closed

missing filters: $__loc__, input_filename, input_line_number #90

pkoppstein opened this issue Jul 13, 2021 · 5 comments

Comments

@pkoppstein
Copy link

The following appear to be undefined in gojq but are documented in detail on the jq "man" page.

$__loc__
input_filename
input_line_number

lgamma_r is not mentioned on that page, but lgamma is.

Other filters that are listed by jq's builtins but not gojq's:

<   "get_jq_origin/0"
<   "get_prog_origin/0"
<   "get_search_list/0"
<   "scalars_or_empty/0"
@itchyny
Copy link
Owner

itchyny commented Jul 14, 2021

Sorry but these are unlikely to be implemented in gojq.

@itchyny itchyny closed this as completed Jul 14, 2021
@pkoppstein
Copy link
Author

I hope you won't mind if I try to persuade you to reconsider input_filename. My main motivation is simply utility. I realize it may not be useful to you but hopefully the implementation would be trivial for you, and I assume that you have invested the time in developing gojq at least in part because of its potential utility to others.

In my own work, I use input_filename in order to have fast JSON-oriented grep-like functionality. For example, given a directory with thousands of JSON files, which ones contain JSON matching a complex condition?

Of course I realize that input_filename is not absolutely necessary for this functionality, but my library already uses it freely, which gets back to the point about consistency with jq's published "specification", at least in regard to useful functionality ....

@itchyny itchyny reopened this Jul 14, 2021
@itchyny
Copy link
Owner

itchyny commented Jul 14, 2021

I've just implemented input_filename/0. Please confirm the behavior.

@pkoppstein
Copy link
Author

Wonderful! But there is strange bug.

On the one hand, as expected:

$ echo 3 | jqMaster . -
3

But on the other:

$ echo 3 | gojqMaster input_filename one.json two.json -
echo 3 | gojqMaster input_filename one.json two.json -
"one.json"
"two.json"
gojq: open -: no such file or directory

For reference:

$ echo 3 | jq input_filename one.json two.json -
"one.json"
"two.json"
"<stdin>"

itchyny added a commit that referenced this issue Jul 14, 2021
@itchyny
Copy link
Owner

itchyny commented Jul 14, 2021

I implemented hyphen for stdin support.

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

No branches or pull requests

2 participants