I'm using MongoDB via the official C# driver with an ASP.NET MVC web site.
I have the following C# model:
public class Contact
{
public ObjectId Id { get; set; }
public string Name { get; set; }
public DateTime DateAdded { get; set; }
}
{
"_id" : ObjectId("52eaad4839b60812fca4bf28"),
"Name": "Joe Blow",
"DateAdded" : ISODate("2014-01-30T19:51:35.977Z")
}
Uncaught SyntaxError: Unexpected token I
ISODate(...)
ObjectId()
string.replace()
ISODate()
I think you need to tweak your JSON serializer a bit more. Try this:
var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict };
Console.WriteLine(document.ToJson(jsonWriterSettings));