问题
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