编程语言
首页 > 编程语言> > asp.net core 默认采用小驼峰命名

asp.net core 默认采用小驼峰命名

作者:互联网

 1             services.AddMvc(options =>
 2             {
 3                 options.Filters.Add<ApiExceptionAttribute>();
 4             }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
 5              .AddJsonOptions(options =>
 6              {
 7                  options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();//JSON首字母小写解决
 8                  options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
 9                  //返回Json属性命名默认按照小驼峰规则
10                  options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
11              });

 

标签:core,asp,驼峰,ContractResolver,Json,new,SerializerSettings,net,options
来源: https://www.cnblogs.com/yanglang/p/11911492.html