有没有办法将mongo集合转储为json格式?要么在shell上,要么使用java驱动程序.我在找性能最好的.

推荐答案

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>

Also helpful:

-o: write the output to file, otherwise standard output is used (docs)

--jsonArray: generates a valid json document, instead of one json object per line (docs)

--pretty: outputs formatted json (docs)

Json相关问答推荐

PowerShell脚本未按预期生成预期的JSON输出

Azure数据工厂-WEB活动输出赢得';t返回JSON

递归解码嵌套列表(具有任意深度的列表列表)

将 REST API - json 输出转换为表 Power BI

基于 JSON 字段的 Jolt 条件标志

展平多个数组以保持顺序

Vega-Lite规范:尽管在规范中提供了数据,但显示空图表

APIM 生成 JsonArray 到 EventHub

正向闪烁后的微调值

小写嵌套特定键的震动转换

JSONPath:查找子项目条件在字符串列表中的项目

golang递归json来构造?

如何使用 Google 表格应用程序脚本将 JSON 中的多个字段提取到 Google 表格中

流编写器未写入 webapi 中的 JSON 文件

如何使用 jq 返回此 JSON 文件的文本字段?

从 HttpResponse 获取 json

有必要清理 JSON 吗?

如何在 Rails 模型中验证字符串是否为 json

获取一个数字的 PHP 对象属性

从 Json 对象 Android 中获取字符串值