Search code examples
mongodbimportcompass

"Operation passed in cannot be an array" compass error - but JSON isn't an array


Trying to import simple data (see below), gets me an error "Operation passed in cannot be an array" in Compass 1.29.6

This error makes no sense to me, as the outer object is not an array. Sure, the first object contains an array, but how is this not importable, since it is valid JSON? What is it expecting?

I have checked the documentation for Compass, perused other similar errors, no answers are obvious or relevant enough to help me.

{
   "Name": "root",
   "ID": 0,
   "Children": [{
    "Name": "Chocolates",
    "ID": 1,
    "ParentID": 0
   }]
}

Solution

  • I am a bit late but try to wrap your object into array like

    [{
       "Name": "root",
       "ID": 0,
       "Children": [{
        "Name": "Chocolates",
        "ID": 1,
        "ParentID": 0
       }]
    }]
    

    it will work