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

DistribuzioneGaussiana
  • 1,879
  • 5
  • 24
  • 49
  • 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

37

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
  • 2,803
  • 2
  • 25
  • 48
Rohit Jain
  • 1,893
  • 14
  • 18