Brivvirs Brivvirs - 20 days ago 5
C# Question

asp.net core 1.0 web api use camelcase

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

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

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

Comments