Hi, I’m getting an error using mongoimport (version r4.2.6) saying that it cannot decode array into a D. I’ve already added the --jsonArray option. The json was created by a python API that I’m running from the command line.
The error related to an array type from the document(s) in the file.
You mentioned that the JSON was created by a Python API. If the documents in the file is consistent in structure, could you provide just one document ?
Hi Wan, I’ve attached the image of the json file. Is there a way for me to send you the actual json? If I edit the file down myself then mongo imports it properly (I’m using Compass / Add Data / Import File from within the Collection). The file size is 21k.
Hi @Rich_Farrell it would probably help if you put the file in a pastebin, gist or something similar (if possible) so @wan can download and work with the actual data.
Thanks for providing a sample file. Looking at the file, the problem with the json file is that it contains an array of array documents. Currently this is the structure of your file:
[ [ {"text":"one"}, {"text":"two"} ] ]
The format should be as below:
[ {"text":"one"}, {"text":"two"} ]
Try updating your Python script to output an array of dictionaries instead of an array of array of dictionaries, and try running mongoimport again.