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(); });
This keeps a JSON object's name the same as .NET class property.
You can configure JSON behavior this way:
public void ConfigureServices(IServiceCollection services) { services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With