0

I have some json files formatted in the following way

{
  <collection_name> : [
    {object}, 
    {object}
  ]
}

Is there any mongo script I can use to import this kind of files or a preparsing to pass in the correct format to mongoimport?

Update: Using philshem's command line my input gives me the following error:

exception:BSON representation of supplied JSON array is too large: code FailedToParse: FailedToParse: Date expecting integer milliseconds: offset:264

The date in question is

"uploadDate": {
  "$date": "2015-02-17T10:36:34.881Z"
}
Pedro Montoto García
  • 1,672
  • 2
  • 18
  • 38

2 Answers2

4

The standard import line is:

mongoimport --db dbName --collection collectionName --file fileName.json

For an array of json objects, add this flag:

--jsonArray

(read more)

If you tried this and it didn't work, please edit your question to include the error message.


Update: Based on the error message, check out this question/answer and this documentation.

Community
  • 1
  • 1
philshem
  • 24,761
  • 8
  • 61
  • 127
0

You need to explicitly de format of date

Try this:

"uploadDate": {
  "$date": **ISODate(**"2015-02-17T10:36:34.881Z"**)**
}
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Jhonatan
  • 91
  • 8