Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get JSON file from mongodump

I'm trying to export one of my mongo collections using this command:

"C:\Program Files\MongoDB\Server\3.2\bin\mongodump" -h 127.0.0.1 --port 3001 -d meteor

I have a BSON file with my db collection but i want it in a JSON file.

How can I do it?

like image 943
alpheonix Avatar asked Nov 21 '17 15:11

alpheonix


1 Answers

From the docs:

mongodump is a utility for creating a binary export of the contents of a database

--out , -o

Specifies the directory where mongodump will write BSON files for the dumped databases

So mongodump outputs BSON.

If you want to output JSON then you have to use mongoexport. From the docs:

mongoexport is a utility that produces a JSON or CSV export of data stored in a MongoDB instance

For example:

"C:\Program Files\MongoDB\Server\3.2\bin\mongoexport" -h 127.0.0.1 --port 3001 -db <database name> --collection <collection name> --out mongo_output.json
like image 120
glytching Avatar answered Oct 14 '22 03:10

glytching