.netcore2.1 统一设置接口返回字段骆驼形式  

 services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1).AddJsonOptions(options =>
            {
                //全局格式化处理
                options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
                // DefaultContractResolver 设置默认单词首字母大写 如UserName,
                //CamelCasePropertyNamesContractResolver 设置默认采用骆驼命名规则 如userName
                options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            });

 

  在StartUp类中的配置服务中添加如上代码

 

posted @ 2020-10-26 14:41  低调码农哥!  阅读(545)  评论(0编辑  收藏  举报