/// <summary>
/// 将对象转换成json字符串
/// </summary>
/// <param name="obj">对象</param>
/// <param name="dateFormat">对象中日期要转换的格式</param>
/// <returns></returns>
public static String Json(object obj, String dateFormat = "yyyy-MM-dd")
{
string strjson= JsonSerializer.Serialize(obj);
strjson = Regex.Replace(strjson, @"\\/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(dateFormat);
});
return strjson;
}