I have a zip archive with a lot of JSON files. Each of these JSON files is an array of JSON objects that I would like to import to a MongoDB collection. My idea was to use the pipe option of unzip and send the content of these files directly to mongoimport:
unzip -p archive.zip *.json | mongoimport -d db_name -c collection_name --jsonArray
I expected a similar behavior to what piping a find result does: each file is processed correctly, like with this command:
find . -type f -name "*.json" | zip archive.zip -@
But it isn't. Since the contents of the files is output to std, the mongoimport has a problem, because it gets a beginning of an array from another file right after an end of an array from the previous file. Nothing in between (apart from the newline I guess), so it stops.
Is there any other way to achieve my goal?