Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB import error : Failed: error reading separator after document #1: bad JSON array format - found no opening bracket '[' in input source

Tags:

json

mongodb

Here is my json file :

{"a":"b"}

When i am importing this file in database by this command:

mongoimport --db test --collection abc --jsonArray --file ABC.json

I got this error :

2016-11-10T15:03:39.696+0530    connected to: localhost
2016-11-10T15:03:39.697+0530    Failed: error reading separator after document #1: bad JSON array format - found no opening bracket '[' in input source
2016-11-10T15:03:39.697+0530    imported 0 documents

in my console.

There is no '[' symbol in my file. Can someone tell me where i am wrong?

like image 552
hedha Avatar asked Nov 10 '16 09:11

hedha


1 Answers

Since you included the option --jsonArray, you must provide an array: [{"a":"b"}].

If you provide a single document, do not use the option --jsonArray.

like image 82
dgiugg Avatar answered Oct 11 '22 10:10

dgiugg