mongoimport --db my_db --collection mycol --file "D:\workspace\intelligent_TDR\charm\employees.json" --jsonArray
Importing the employees.json file using the above command gives me the error
Failed: error reading separator after document #1: bad JSON array format - found no opening bracket '[' in input source
The content of json file is
{"employees":[
{ "firstName":"John", "lastName":"Doe" },
{ "firstName":"Anna", "lastName":"Smith" },
{ "firstName":"Peter", "lastName":"Jones" }
]}
If I place the content within '[' and ']' the import works.
The below json is imported without error
[{"employees":[
{ "firstName":"John", "lastName":"Doe" },
{ "firstName":"Anna", "lastName":"Smith" },
{ "firstName":"Peter", "lastName":"Jones" }
]}]
--jsonArrayoption if you don't have an array as your input?