With my need to exchange data between a ASP.NET and PHP web applications, I decided to use JSON. The .NET team did a good job by integrating JSON de/serialization into the language (NET 3.5) but they decided not to follow JSON specifications for some good reasons. Serializing an object that has a DateTime property will insert a string that won’t be understood by json_decode of PHP.
On the site of JSON, there is no such thing as a date type. I have taken the ISO 8601 path which is my preferred date format (MySQL and Swedish Locale standard)
Consider the following class:
-
[DataContract]
-
public class Person
-
{
-
[DataMember]
-
public DateTime DateOfBirth { set; get; }
-
[DataMember]
-
public string Names { set; get; }
-
}
By Serializing it you will get something like
That Date is not defined as a JSON type. In case your JSON will be used directly by JavaScript or .NET (C#, VB) you will not need to write extra codes.