JavaScriptSerializer序列化時間後會把時間序列化成N進制的鬼數據,於是查了下質料坐下記錄
假設list = News List<Text>(){new Text(){id=1,date='2014-03-11 00:00:00.000'}}
JavaScriptSerializer serializable = new JavaScriptSerializer(); string json = serializable.Serialize(new { total = total, rows = list}); //使用正則表達式來替換被序列化的時間 json = System.Text.RegularExpressions.Regex.Replace(json, @"\\/Date\((\d+)\)\\/", match => { DateTime dt = new DateTime(1970, 1, 1); dt = dt.AddMilliseconds(long.Parse(match.Groups[1].Value)); dt = dt.ToLocalTime(); return dt.ToString("yyyy-MM-dd HH:mm:ss"); }); return json;