18

I have this MongoDB document. In JSON:

{
"attString":"hello World0",
"attInt":0,
"attDate":new Date("1990-7-20")
 }
        

How can I import this document into MongoDB using mongoimport? I have a problem with the attDate field.

This is MongoDB shell notice:

Failed: error unmarshaling bytes on document #1: unexpected ISODate format

harry-potter
  • 1,981
  • 5
  • 29
  • 55
  • Possible duplicate of [Mongoimport of json file](http://stackoverflow.com/questions/15171622/mongoimport-of-json-file) – Pio Oct 13 '15 at 16:20

1 Answers1

38

You have to change your date format in JSON

Either

{"attString":"hello World0","attInt":0,"attDate":ISODate("2013-11-20T23:32:18Z")}

OR

{"attString":"hello World0","attInt":0,"attDate":{"$date":"2013-11-20T23:32:18Z"}} 

Hope it will help

Edson Horacio Junior
  • 3,033
  • 2
  • 29
  • 50
Rohit Jain
  • 2,052
  • 17
  • 19