Alexander Zeitler

Alexander Zeitler

lowerCamelCase JSON with ASP.NET MVC 6

Published on Friday, May 1, 2015

With ASP.NET MVC 6 the default output for JSON is still UpperCamelCase.

To change that to lowerCamelCase JSON, simply add this to the ConfigureServices method:

Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
   
    services.ConfigureMvc(options =>
    {
        (options.OutputFormatters.First(f => f.Instance is JsonOutputFormatter).Instance as
            JsonOutputFormatter).SerializerSettings.ContractResolver = 
            new CamelCasePropertyNamesContractResolver();
    });
}

That's it!

What are your thoughts about "lowerCamelCase JSON with ASP.NET MVC 6"?
Drop me a line - I'm looking forward to your feedback! email
Imprint | Privacy