asp.net 1.0核心API的网络使用驼峰 [英] asp.net core 1.0 web api use camelcase

查看:199
本文介绍了asp.net 1.0核心API的网络使用驼峰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在RC2骆驼情况相同的代码返回JSON格式。核心1.0版本后,我开始新的项目,相同的代码返回小写的JSON。





尝试过多种解决方案,但他们没有解决的问题
Web的API -serialize - 属性 - 开始 - 从小写字母


解决方案

  services.AddMvc()
.AddJsonOptions(选项=>
{
options.SerializerSettings.ContractResolver =新Newtonsoft.Json.Serialization.DefaultContractResolver();
});

这一直JSON对象名称相同的.NET类属性。


On rc2 the same code return json format with camel case. After core 1.0 release i started new project and the same code is returning json in lowercase.

Tried multiple solutions but none of them solved problem web-api-serialize-properties-starting-from-lowercase-letter

解决方案

 services.AddMvc()
               .AddJsonOptions(options =>
               {
                   options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
               });

this keeps json object name the same as .net class property.

这篇关于asp.net 1.0核心API的网络使用驼峰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆