标签:add options case serialize figure style 全局配置 key newton
JsonSerializerSettings settings = new JsonSerializerSettings(); //EF Core中默认为驼峰样式序列化处理key //settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); //使用默认方式,不更改元数据的key的大小写 settings.ContractResolver = new DefaultContractResolver(); return Json(data, settings);
全局设置,Json序列化配置
public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc() //全局配置Json序列化处理 .AddJsonOptions(options => { //忽略循环引用 options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; //不更改元数据的key的大小写 options.SerializerSettings.ContractResolver = new DefaultContractResolver(); } ); }
Net Core中使用Newtonsoft.Json进行序列化保持原有大小写
标签:add options case serialize figure style 全局配置 key newton
原文地址:https://www.cnblogs.com/zmaiwxl/p/9229143.html