Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSON Camelcase properties
// Add framework services.
services.AddMvc(options =>
{
var json = options.OutputFormatters
.OfType<JsonOutputFormatter>()
.FirstOrDefault();
if (json != null)
{
json.SerializerSettings.ContractResolver =
new CamelCasePropertyNamesContractResolver();
}
});
@khellang

This comment has been minimized.

Copy link

commented Mar 14, 2016

There's also a slightly easier way:

services.AddMvc()
    .AddJsonOptions(options =>
        options.SerializerSettings
            .ContractResolver = new CamelCasePropertyNamesContractResolver());

😁👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.