Unexpected end of JSON input with MongoDB Compass

独自空忆成欢 提交于 2019-12-24 11:28:29

问题


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:

That's how my JSON file looks like:

{..."settings":{"inventory":{"crate":{"$numberInt":"0"},"cratekey":{"$numberInt":"0"},"pickaxe":{"$numberInt":"0"},...}

(I don't know if it's relevant to answer this question but this JSON line is just 1/142000)

How can I fix this error?


回答1:


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.




回答2:


I had exact same problem, apparently their should be one document per line. However use https://studio3t.com/ it'll work fine.



来源:https://stackoverflow.com/questions/55206265/unexpected-end-of-json-input-with-mongodb-compass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!