C# Newtonsoft.Json JsonSerializerSettings 全局序列化设置

2021-07-11 08:06

阅读:407

});

 

序列化时 指定Key的处理方式,为驼峰式  

CamelCasePropertyNamesContractResolver

//设置序列化时key为驼峰样式

JsonSerializerSettings settings = new JsonSerializerSettings();

settings.ContractResolver = new CamelCasePropertyNamesContractResolver();

settings.Formatting = Formatting.Indented;

string str = JsonConvert.SerializeObject(menus, settings);

 

 


评论


亲,登录后才可以留言!