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

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


No comments:

Post a Comment