.net对象转json,键是小写的

1.创建自定义合同解析器。

public class LowercaseContractResolver : DefaultContractResolver
{
    protected override string ResolvePropertyName(string propertyName)
    {
        return propertyName.ToLower();
    }
}

2.调用

var settings = new JsonSerializerSettings();
settings.ContractResolver = new LowercaseContractResolver();
var json = JsonConvert.SerializeObject(this, Formatting.Indented, settings);

.net对象转json,键是小写的

上一篇:Jmeter测试接口详细步骤(二)HTTP Cookie管理器


下一篇:用IDEA写HTML