我正在尝试使用 Compass 将 the following json file 导入 MongoDB,但出现错误:
Unexpected token � in JSON at position 0 while parsing near '�' in C:\Users\antoi\Downloads\restaurants.json
> 1 | �
| ^
然后我尝试从另一个来源对其进行测试,但没有奏效:
Error: Parse error on line 10:
...s Park Bake Shop"} { "_id": { "$oid"
----------------------^
Expecting 'EOF', '}', ',', ']', got '{'
是否缺少引号?但是当我添加引号时,它给了我:
Error: Parse error on line 10:
...is Park Bake Shop"}, { "_id": { "$oi
----------------------^
Expecting 'EOF', got ','
答案 0 :(得分:1)
mongoimport --db myDb --collection restaurants --file restaurants.json
<块引用>
restaurants.json
不是有效的 JSON,未包装在数组中,末尾也没有逗号。
https://docs.mongodb.com/manual/reference/mongodb-extended-json/