Thursday, October 1, 2015

ASP.NET 5 and camelCase JSON

As you know in .NET we all use PascalCase and in JavaScript we use camelCase. In order to sync the ASP.NET and SPA application that use JavaScript, we have CamelCasePropertyNamesContractResolver. Here is the code on how to configure this contract resolver in ASP.NET 5.0

services.AddMvc()
    .AddJsonOptions(options =>
    {
        options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        options.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore;
        options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;

    }); 

1 comment:

  1. Shop Online in Auckland Newzealand on a single click. We provide you quality items which you will be buy online at lowest price..! Buy online sofa beds nz at lowest price on Treasurebox store.

    ReplyDelete