.net core json序列化首字符小写和日期格式处理

打开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";
   })
}

 



posted @ 2019-04-09 09:53  576  阅读(724)  评论(0编辑  收藏  举报