.NET has PascalCase naming convention for properties while Javascript has camelCase. Is there an easy way to convert the Json result? The answer is Json.NET. This article will show you how to create a custom result with Json.NET.
Install Newtonsoft.Json Nuget Package
Custom Action Result
We use CamelCasePropertyNamesContractResolver to convert PascalCase into camelCase.
Controller Extension Method
This extension method can save us some typing. We can use this.JsonCamelCase([data]) in any controllers. Or you can put this method into your base controller if you have one.
Usage
‘FancyName’ will be changed to ‘fancyName’ in the result.