打开Startup.cs文件,在ConfigureServices方法中添加如下代码
public void ConfigureServices(IServiceCollection services){
services.AddMvc().AddJsonOptions(option=>{
//配置大小写问题,默认是首字母小写
option.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
//配置序列化时时间格式为yyyy-MM-dd HH:mm:ss
option.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
})
}