var user =new{ Name ="jojo", Age =29};var serializerSettings =newJsonSerializerSettings{// 设置为驼峰命名
ContractResolver =newCamelCasePropertyNamesContractResolver()};var userStr = JsonConvert.SerializeObject(user, Formatting.None, serializerSettings);
使用newtonsoft.json来设置格式化的方式(推荐使用)var user = new { Name = "jojo", Age = 29 }; var serializerSettings = new JsonSerializerSettings { // 设置为驼峰命名 ContractResolver = new CamelCasePropertyNamesContractResolver()