On RC2 the same code returns json format with camel case. After netcore 1.0 release i started new project and the same code is returning json in lowercase.

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

推荐答案

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

这将使JSON对象的名称与相同.NET类属性.

Json相关问答推荐

基于两个条件替换扁平化的SON中的值

try 将文本标记放置在条形图上的同一高度

Swift解码错误类型与`Bool`type不一致

Jolt将键和值转换为单独的数组集

与错误相关的未定义&Quot;不是有效的JSON

PowerShell脚本未按预期生成预期的JSON输出

JQ:获取该值的较短语法是什么

如何对未知/变量键的字典进行编码?

如何使NiFi将数据库单列中的多个值转化为Solr索引中的数组?

jq EOF 处的无效数字文字将 json 值更新为 0.0.x

如何使用 gson 调用默认反序列化

JSON 语法错误:'unexpected number' 或 'JSON.parse: expected ',' or '}' after property value in object'

Spring Security 和 JSON 身份验证

如何将有向无环图 (DAG) 存储为 JSON?

如何向从文件中检索的 JSON 数据添加键值?

waitUntilAllTask​​sAreFinished 错误 Swift

我可以使用空字符串作为对象标识符吗?

强制 JSON.NET 在序列化 DateTime 时包含毫秒(即使 ms 组件为零)

如何对 jq 中的 map 数组中的值求和?

Javascript:如何判断 AJAX 响应是否为 JSON