Json.net默认的时间格式化后带T,不符合一般的业务要求,重新设置JSON.NET的默认日期格式化方式,代码如下:
/// <summary>
/// Json.net默认转换设置
/// </summary>
private static void DefaultJsonConvertSetting()
{
JsonSerializerSettings setting = new JsonSerializerSettings();
JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() =>
{
//日期类型默认格式化处理
setting.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
setting.DateFormatString = "yyyy-MM-dd HH:mm:ss"; //空值处理
//setting.NullValueHandling = NullValueHandling.Ignore; return setting;
});
}