标签:
public string ToJson<T>(T t) { JavaScriptSerializer jss = new JavaScriptSerializer(); var json = jss.Serialize(t); MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString); Regex reg = new Regex(@"\\/Date\((\d+)\)\\/"); var newjson = reg.Replace(json,matchEvaluator); return newjson; } public string ConvertJsonDateToDateString(Match m) { string result = string.Empty(); DateTime dt = new DateTime(); var timevalue = m.Groups[0].Value.Replace("\\/Date(“,"").Replace(")\\/",""); long newtime = long.Parse(timevalue); dt = dt.AddMilliseconds(newtime); result = dt.ToString("yyyy-MM-dd HH:mm:ss"); return result; }
标签:
原文地址:http://www.cnblogs.com/linhongquan/p/5332373.html