Closed jordao76 closed 3 years ago
I never used multiple files as input but it seem interesting feature. Could you give me some command line examples?
Thanks
Sure,
I need to concatenate certain JSON files into a single file, and make a JSON object where each key is the original file name and the value is the original file JSON.
I can do this for two files like this:
jq '{ (input_filename|rtrimstr(".json")) : . }' file1.json file2.json | jq -s add
I'm sure there's a way to do it in one jq
command, but you get the idea.
What I actually do is read all files in a folder and do that:
ls -I data.json | xargs jq '{ (input_filename|rtrimstr(".json")) : . }' | jq -s add > data.json
Better late than never, sorry :) Today I checked out the use case, I think I will release something like this
It would be good to support multiple files as input.