Handling ISODate in mongoDB when Deserializing from JSON
-
Hi, First, I didn't see a mongoDB forum here so I think that's the closest place to ask a DB question. Ok, so I'm using MongoDB in my web application and using C# driver to interact with it. I ran across a problem that I can see a lot of people encountered and that is: How can I deserialize a JSON string that I get from mongo when I have a field, called DateAndTime which has the value much like this one: ISODate("2014-04-19T06:01:17.171Z") I get an exception that this is, and of course it is, an invalid JSON type. I came across a solution in Stackoverflow which said to do this:
string json; // Assign JSON here.
var v = Newtonsoft.Json.JsonConvert.DeserializeObjectAsync(json);but this also didn't helped. How can I get around this issue or solve it? Or perhaps is there a way to configure how mongo will save dates?