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.
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