我想将 MongoDB 的 BSON 转储转换为 JSON。
为此,我使用了 bsondump Mongo 提供的工具,但我得到如下输出:
{ "_id" : ObjectId( "5316d194b34f6a0c8776e187" ), "begin_date" : Date( 1394004372038 ), "foo" : "bar" }
{ "_id" : ObjectId( "5316d198b34f6a0c8776e188" ), "begin_date" : Date( 1394004407696 ), "foo" : "bar" }
谁能告诉我如何让日期以人类可读的格式显示(例如 hh:mm:ss dd/mm/yyyy
)?
编辑
看起来更新版本的 mongodump 输出日期为:
{ "_id" : ObjectId( "5316d194b34f6a0c8776e187" ), "begin_date" : {"$date":"2015-11-11T08:45:03.974Z"}}, "foo" : "bar" }
所以这个问题不再相关了。 在此感谢大家的帮助。
最佳答案
bsondump converts BSON files into human-readable formats, including JSON. For example, bsondump is useful for reading the output files generated by mongodump.
来源:https://docs.mongodb.com/manual/reference/program/bsondump
示例
bsondump --outFile collection.json collection.bson
--pretty
选项以漂亮的 JSON 格式输出文档,例如:
bsondump --pretty --outFile collection.json collection.bson
关于json - 如何将 BSON 转换为具有人类可读日期格式的 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23010566/