问题描述
我使用PC上的JSON文件类型导出了本地 MongoDB集合.然后,我想使用MongoDB Compass在我的根服务器上导入这些Collections.
I exported my local MongoDB Collections using the JSON file type on my pc. Then I wanted to import these Collections on my root server using MongoDB Compass.
每次我尝试导出集合时,都会引发以下错误:
Everytime when I try to export the Collection, it throws the following error:
这就是我的JSON文件的样子:
That's how my JSON file looks like:
{..."settings":{"inventory":{"crate":{"$numberInt":"0"},"cratekey":{"$numberInt":"0"},"pickaxe":{"$numberInt":"0"},...}
(我不知道回答这个问题是否相关,但是此JSON行仅为1/142000)
(I don't know if it's relevant to answer this question but this JSON line is just 1/142000)
如何解决此错误?
推荐答案
我不知道这是否对您有帮助,但是在尝试导入json数据时遇到了类似的问题.我每行只有1个文档,但是还是有些问题.然后,我导出了与json类似的数据,并尝试对其进行处理以查看引起问题的原因.事实证明,json的底部必须有一个空行.假设您要导入1个文档.您将整个文档放在第一行.然后,您只需按Enter并在底部创建第二行.之后,我的数据导入就没有问题了.
I don't know if this will help your case, but I ran into a similar issue when trying to import json data. I had 1 document per line, but something was still wrong. I then exported a similar piece of data as json, and tried playing around with it to see what was causing the issue. It turns out that the json must have an empty line at the bottom. So let's say you have 1 document to import. You place the entire document onto the first line. Then you just hit enter and create the second line at the bottom. After this, my data was imported without a problem.
这篇关于MongoDB Compass的JSON输入意外结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!