views:

112

answers:

1
MyClass theSession = new MyClass()
                {
                    accountId = 12345,
                    timeStamp = DateTime.Now,
                    userType = "theUserType"
                };

System.Web.Script.Serialization.JavaScriptSerializer Json = new System.Web.Script.Serialization.JavaScriptSerializer();
        Response.Write(Json.Serialize(theSession));

Produces:

{"accountId":12345,"timeStamp":"\/Date(1268420981135)\/","userType":"theUserType"}

How can I present the date as:

"timestamp":"2010-02-15T23:53:35.963Z"

?

+1  A: 

You need to make a JavaScriptConverter class and register it using the RegisterConverters method.

SLaks