MongoDB Atlas mongoimport issues cannot decode array into a D
Asked Answered
F

1

53

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.
Fere answered 28/9, 2019 at 21:42 Comment(1)
Did you find out why? I am facing the exact issueYetac
Y
164

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.

Yetac answered 1/10, 2019 at 1:12 Comment(2)
latest document is here docs.mongodb.com/database-tools/mongoimportMugwump
Thank you so much for this. Helped immensely. My question is - what was your thought process in finding this solution? I'd like to learn how to solve things better on my own. Unfortunately, the error message "cannot decode array into a D" seemed entirely unhelpful to me.Puritanical

© 2022 - 2024 — McMap. All rights reserved.