2010-03-12 18 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

回答