Skip to content

Instantly share code, notes, and snippets.

@nbellocam
Created March 14, 2016 13:14
Show Gist options
  • Save nbellocam/147a7d47c7a90490798e to your computer and use it in GitHub Desktop.
Save nbellocam/147a7d47c7a90490798e to your computer and use it in GitHub Desktop.
Asp.net core: Configure MVC to use camelCase for json serializer
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
options.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Include;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});
@yingDev
Copy link

yingDev commented Jul 24, 2020

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllersWithViews().AddJsonOptions(opts => opts.JsonSerializerOptions.PropertyNamingPolicy = null);
    }

@ngnam
Copy link

ngnam commented Aug 2, 2021

Default in .netcore5 hadd is casePascal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment