Slashes added to DateTime Serialization

Jun 2, 2008 at 9:31 PM
I was just wondering why slashes "/" are added before and after the date when its serialized (eg \/Date(123456789)\/)? The method I'm looking at is JavaScriptConvert.ToStringInternal.
Thanks.
Coordinator
Jun 8, 2008 at 8:53 AM
http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx
Jun 9, 2008 at 1:33 AM
I was actually doing that very thing (replacing the \/Date/\ with new Date()) I just couldn't figure out why it wasn't done on the server side, but now I know. Thanks.
Coordinator
Jun 9, 2008 at 8:38 AM
FYI there is a JsonConverter that comes with Json.NET which outputs 'new Date()'
Jun 12, 2008 at 1:43 PM
apparently, jQuery does not like parsing JSON with dates in this format. it returns them as a string like so:

/Date(334540800000)/

It is possible to parse this into a usable javascript date object but a pain none the less.

I am using Castle MonoRail, and the latest version of the trunk is using Json.net 2.0, but because of the difficulty of getting all three frameworks to play nicely I went back to 1.3.2 in which MonoRail is outputting the dates as new Date()

Any easy way of getting this to work with the jQuery JSON parser?
Coordinator
Jun 14, 2008 at 3:35 AM
Use the JavaScriptDateTimeConverter when serializing...