Is there any way to dump mongo collection into json format? Either on the shell or using java driver.I am looking for the one with best performance.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Mongo includes a mongoexport utility (see docs) which can dump a collection. This utility uses the native libmongoclient and is likely the fastest method.
Also helpful:
-o: write the output to file, otherwise standard output is used (docs)--jsonArray: generates a valid json document, instead of one json object per line (docs)--pretty: outputs formatted json (docs)