2010-03-12 40 views
3
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)); 

产地:强迫JSON序列成产生特定的日期时间格式(YYYY-MM-DDTHH:MM:ss.msmsmsZ)

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

我可以如何呈现的时间为:

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

+0

你总是可以有你的JS把它解释为你 – 2010-03-12 19:24:19

回答