Luispe Reyes
Luispe Reyes

Reputation: 81

How to import json file to mongo through mac terminal?

I'm using this command

mongoimport --db test --collection bankdata --drop --file bank_data.json --port 27017 --host 127.0.0.1

to import a json file, but when I do it I get this message

Failed: error unmarshaling bytes on document #0: JSON decoder out of sync - data changing underfoot? 2016-05-24T08:00:31.552-0600 imported 0 documents

Upvotes: 3

Views: 3628

Answers (1)

milosnkb
milosnkb

Reputation: 1591

You are trying to import json array ,so you need to add --jsonArray option according to documentation https://docs.mongodb.com/manual/reference/program/mongoimport/

mongoimport --jsonArray --db test --collection bankdata --drop --file bank_data.json

Upvotes: 3

Related Questions