.NET Core by default, converts the class property names to Camel case when we serialize the JSON object.
e.g. I have defined my class as below
when we serialize this class, the web API will return as following
So in order to make it as the property names as same as the class property name like below
we need to override the ContractResolver in JSON serialization settings.
e.g. I have defined my class as below
when we serialize this class, the web API will return as following
we need to override the ContractResolver in JSON serialization settings.
services .AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); });Note: AddJsonOptions method will be available in Microsoft.Extensions.DependencyInjection.MvcJsonMvcBuilderExtensions class
Really helpful. Please post some information above AWS.
ReplyDelete