How to convert BSON to JSON with human-readable date format

前端 未结 2 1343
忘掉有多难
忘掉有多难 2021-02-11 18:05

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 :

{ \"_i         


        
相关标签:
2条回答
  • 2021-02-11 18:15

    To create a JSON file directly from the database, use mongoexport

    mongoexport --db myDatabase --collection myCollection --jsonArray --out myJsonFile.json
    
    0 讨论(0)
  • 2021-02-11 18:26

    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
    
    0 讨论(0)
提交回复
热议问题