I would like to transform a BSON dump of MongoDB to JSON.
To do that, I'm using the bsondump tool provided with Mongo, but I get an output like :
{ "_id" : ObjectId( "5316d194b34f6a0c8776e187" ), "begin_date" : Date( 1394004372038 ), "foo" : "bar" } { "_id" : ObjectId( "5316d198b34f6a0c8776e188" ), "begin_date" : Date( 1394004407696 ), "foo" : "bar" }
Can anyone tell me how to get the dates appear in a human readable format (e.g. hh:mm:ss dd/mm/yyyy
) ?
Edit
It looks like that a more recent version of mongodump outputs dates as:
{ "_id" : ObjectId( "5316d194b34f6a0c8776e187" ), "begin_date" : {"$date":"2015-11-11T08:45:03.974Z"}}, "foo" : "bar" }
So this question is not relevant anymore. Thanks everybody for your help here.
Synopsis. The bsondump converts BSON files into human-readable formats, including JSON.
BSON needs to be parsed as they are machine-generated and not human-readable.
If you cannot open your BSON file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a BSON file directly in the browser: Just drag the file onto this browser window and drop it.
bsondump converts BSON files into human-readable formats, including JSON. For example, bsondump is useful for reading the output files generated by mongodump.
Source: https://docs.mongodb.com/manual/reference/program/bsondump
Examples
bsondump --outFile collection.json collection.bson
The --pretty
option outputs documents in a pretty-printed format JSON, eg:
bsondump --pretty --outFile collection.json collection.bson
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With