//这是驼色 shell

    services.AddMvcCore()
        .AddJsonOptions(options =>
        {
            options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        })

如何设置为带下划线的小写?
{
  "just_like_this": "myvalue",
}

最佳答案

您可能希望将 SnakeCaseNamingStrategyDefaultContractResolver 一起使用

DefaultContractResolver contractResolver = new DefaultContractResolver
{
    NamingStrategy = new SnakeCaseNamingStrategy()
};

services
    .AddMvcCore()
    .AddJsonOptions(options => {
        options.SerializerSettings.ContractResolver = contractResolver;
    });

引用 Snake case property names

关于c# - ContractResolver,带下划线的小写字母(蛇形大小写属性名称)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51572218/

10-13 09:05