AjaxPro JSON Parser and Dates

Michael Schwarz on Friday, September 22, 2006

Because there are a lot of developers using the stand-alone JSON parser (which is included in the release package of AjaxPro [1]) I decided today to serialize the .NET data type System.DateTime with the UniversalSortableDateTimePattern (yyyy'-'MM'-'dd HH':'mm':'ss'Z') as a simple string. You can use this string as input value, too, it will be parsed to an .NET System.DateTime.

Below you will find an example how to use the different JSON outputs in a simple ConsoleApplication:

JavaScriptSerializer.Serialize(DateTime.Now)  JavaScriptDeserializer.DeserializeFromJson<DateTime>(json)  UniversalSortableDateTimePattern 

The output will be similar to this:

"2006-09-22 09:49:18Z"22.09.2006 09:49:18
22.10.2006 12:00:00
23.07.1977 03:13:49
20.09.2006 12:23:02

Note: when using AjaxPro for ASP.NET web application you will still get the JavaScript Date object.