15

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?

1 Answer 1

35

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.

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

2 Comments

I did not provide an array so I deleted --jsonArray. And it worked. Thanks
It saved my life. Thank you!

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.