lowerCamelCase JSON with ASP.NET MVC 6

Written on May 01, 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:


public void ConfigureServices(IServiceCollection services)

    services.ConfigureMvc(options =>
        (options.OutputFormatters.First(f => f.Instance is JsonOutputFormatter).Instance as
            JsonOutputFormatter).SerializerSettings.ContractResolver = 
            new CamelCasePropertyNamesContractResolver();

That's it!