MongoDB Atlas mongoimport issues cannot decode array into a D

majortom84 picture majortom84 · Sep 28, 2019 · Viewed 11.3k times · Source

I'm new to mongoDB and have a free Atlas account. But, I'm having issues with the mongo import.

system: windows

>mongo --version
MongoDB shell version v4.2.0
git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
allocator: tcmalloc
modules: none
build environment:
    distmod: 2012plus
    distarch: x86_64
    target_arch: x86_64

mongoimport string:

mongoimport --host Cluster0-shard-0/cluster0-shard-00-00-MY.mongodb.net:27017,cluster0-shard-00-01-MY.mongodb.net:27017,cluster0-shard-00-02-MY.mongodb.net:27017 --ssl --username MYUSER --password MYPASS --authenticationDatabase admin --db db --collection coll --type json --file D:\downloads\records.json

But I keep getting this error:

2019-09-28T15:40:33.108-0600    WARNING: ignoring unsupported URI parameter 'replicaset'
2019-09-28T15:40:33.933-0600    connected to: mongodb://cluster...
2019-09-28T15:40:34.076-0600    Failed: cannot decode array into a D
2019-09-28T15:40:34.076-0600    0 document(s) imported successfully. 0 document(s) failed to import.

Answer

daydreamer picture daydreamer · Oct 1, 2019

I just figured out. I had a JSON Array in the file, and for that, I had to append

--jsonArray

It is documented here

with the URL provided.

Hope this helps!