2

I am trying to import the following json file into MongoDB with Compass but I get an error:

Unexpected token � in JSON at position 0 while parsing near '�' in C:\Users\antoi\Downloads\restaurants.json 

> 1 | �
| ^

Then I tried to test it from another source but it didn't work:

Error: Parse error on line 10:
...s Park Bake Shop"} { "_id": {        "$oid"
----------------------^
Expecting 'EOF', '}', ',', ']', got '{'

is a quotation mark missing? But when I add a quotation mark it gives me:

Error: Parse error on line 10:
...is Park Bake Shop"}, {   "_id": {        "$oi
----------------------^
Expecting 'EOF', got ','

1 Answer 1

1

Use mongoimport

mongoimport --db myDb --collection restaurants --file restaurants.json

restaurants.json is not a valid JSON, not wrapped in array nor it has commas at the end.

https://docs.mongodb.com/manual/reference/mongodb-extended-json/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.