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"
}

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to explicitly de format of date

Try this:

"uploadDate": {
  "$date": **ISODate(**"2015-02-17T10:36:34.881Z"**)**
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.