var settings = new JsonSerializerSettings {ContractResolver = new CamelCasePropertyNamesContractResolver() };var requestJson = JsonConvert.SerializeObject(obj, settings);
上面代码 settings 设置的作用是,将一个 C# 对象序列化为 JSON 字符串时,C# 对象的属性名称会自动转换为 camelCase 风格,即首字母小写,其后每个单词的首字母大写。