-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
inputs
skips the first file specified
#2394
Comments
Hey, try to add $ jq ".,inputs" <(echo 1) <(echo 2)
1
2
$ jq -n "inputs" <(echo 1) <(echo 2)
1
2 Might feel be a bit unintuitive but i think it makes sense. |
Thank you very much, @wader! Yeah, it's pretty unintuitive to me – not a jq-guru, and it gets even more confusing after reading the doc:
😄 I confirm adding
|
Yeah the documentation could be clearer, but i understand it's a bit tricky to explain. It makes sense if you think about how How it works is that jq more or less handle all the input files as if they were one big concatenated file. Then it reads one JSON value (that can span between files) at the time until the end, and you can also explicitly read values by calling Here is an example explain most of it: $ jq -n '[input,input,try input catch .]' <(echo -n 1) <(echo 2) <(echo 3)
[
12,
3,
"break"
] I recommend also look into |
Thank you again for providing an additional explanation. The issue is resolved and appears to work as designed. Please close at your discretion. I guess an explicit reference to the |
Some alternative approaches to my original use case: Merge/concatenate arrays from multiple files Using
Couldn't find a use for |
No problem. I think you have to close as i'm not a collaborator on this repo.
Yes that would be good i think. Created #2395 |
👍 If you want to be more explicit you can also use
There is also the combination |
KISS:
|
I have a number (few hundred) of
.json
files which content is array (possibly empty) of objects, and I'm using the following command to merge them:I've discovered the content of one of the files is missing from the result.
To Reproduce
Have three JSON files in a directory:
Issue a command:
The result I'm getting:
Expected behavior
A result of:
Environment (please complete the following information):
Additional context
I'm running in a Git-bash console:
input
also appears to act weird:(I'm not really sure what's the expected outcome with the last one.)
https://stedolan.github.io/jq/manual/v1.6/#IO
The text was updated successfully, but these errors were encountered: