asp.net core json 大小写问题

时间:2022-07-15 00:49:48


返回json 串,首字母小写了,解决办法


public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            //返回json  大小写
            services.AddMvc()
                    .AddJsonOptions( op => op.SerializerSettings.ContractResolver =
                                           new Newtonsoft.Json.Serialization.DefaultContractResolver() );