Mongodb import object with numbers as keys results in array

Hello, @steevej and @Jack_Woehr, I am not sure why its working properly through mongoimport command and why its not through mongo compass,

Import through mongoimport: (Working)

> mongoimport --db dbName --collection collectionName <fileName.json  

This results exact input result:

{
  "_id": { "$oid": "5fe3ff5d909016064978f2bd" },
  "data": {
    "plans": {
      "1": "14",
      "2": "20",
      "3": "40"
    }
  }
}

Import from mongo compass: (Not Working)

This results:

{ 
  "_id": { "$oid": "5fe3ff5d909016064978f2bd" }, 
  "plans": [null, "14", "20", "40"] 
}

Ultimately both are same JSON import and using same JSON file, but results are different why it is happening?

1 Like