将Mongo Collection转储为JSON格式 [英] Dump Mongo Collection into JSON format
本文介绍了将Mongo Collection转储为JSON格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以将mongo集合转储为json格式吗?要么在外壳上,要么使用Java驱动程序.我正在寻找性能最好的一个.
Is there any way to dump mongo collection into json format? Either on the shell or using java driver.I am looking for the one with best performance.
推荐答案
Mongo includes a mongoexport utility (see docs) which can dump a collection. This utility uses the native libmongoclient and is likely the fastest method.
mongoexport -d <database> -c <collection_name>
也有帮助:
-o
:将输出写入文件,否则使用标准输出(文档)
-o
: write the output to file, otherwise standard output is used (docs)
--jsonArray
:生成有效的json文档,而不是每行一个json对象(文档)
--jsonArray
: generates a valid json document, instead of one json object per line (docs)
--pretty
:输出格式化的json( docs )
--pretty
: outputs formatted json (docs)
这篇关于将Mongo Collection转储为JSON格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文