Search code examples
mongodbmongodb-compass

Import JSON to MongoDB with Compass MongoDB


I'm using Compass MongoDB to connect to my MongoDB Atlas. I want to import json collection. When I hit import it says "Done" but nothing is happening. What could be the problem?

enter image description here

My json collection is an array of objects:

enter image description here


Solution

  • The json syntax looks good, even for the _id, however - in my dbs, the _id is a hex string - that is, it's made up completely of numbers 0-9 and letters a-f, with no special characters like the dash/negative sign you have. I would make a sample file with 2 records, eliminate the _id, see if it imports.

    If it does, then make a sample file with those 2 records, with the _id being hex strings, and see if it imports.

    If all 4 of those docs (2 from each batch) import properly, the problem is the _id that's not a hex string.