用于配置
Json Serialize
在里面
Asp.Net Core
你可以使用
AddJsonOptions
具有
JsonSerializerSettings
.
//
// Summary:
// Gets or sets how System.DateTime and System.DateTimeOffset values are formatted
// when writing JSON text, and the expected date format when reading JSON text.
// The default value is "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK".
public string DateFormatString { get; set; }
services.AddMvc()
.AddJsonOptions(opt => {
opt.SerializerSettings.DateFormatString = "yyyy-MM-dd";
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);