Mongodb Mongoimport too large: Failure parsing errors
In my case my file was actually not too large, so the error message was misleading. I had to either put each document in a single line or use --jsonArray
.
So either change the file like:
{ "_id" : "xxxxxxxx", "foo" : "yyy", "bar" : "zzz" }
or change the import command to
mongoimport -d [db_name] -c [col_name] --file [file_with_multi_lined_docs] --jsonArray
if my file stays in the multiple-lines-per-document format
{ "_id" : "xxxxxxxx", "foo" : "yyy", "bar" : "zzz" }
Is your json file only contains a list of records in the data
field? In that case, you need to re-format your json file as a list of records like the following:
{ "id": "xxxxxxxxxxxxxxxxxx", "from": { "name": "yyyyyyyyyyy", "id": "1111111111111" }, "to": { "data": [ { "version": 1, "name": "1111111111111", "id": "1111111111111" } ] }, ...... } { "id": "xxxxxxxxxxxxxxxxxx", "from": { "name": "yyyyyyyyyyy", "id": "1111111111111" }, "to": { "data": [ { "version": 1, "name": "1111111111111", "id": "1111111111111" } ] }, ...... }
Just edit the a few leading/ending lines should be enough if your json file is well formatted.
EDIT: You may need the --jsonArray
option to import from a valid json file. try
mongoimport --db DATABASE_NAME --collection COLLECTION_NAME --file YOUR_JSON_FILE --jsonArray