camelCasing JSON in ASP.NET WebAPI
Simple. In global.asax (or somewhere you define your formatters) use this:
var formatters = GlobalConfiguration.Configuration.Formatters;
var jsonFormatter = formatters.JsonFormatter;
var settings = jsonFormatter.SerializerSettings;
settings.Formatting = Formatting.Indented;
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
This only works with default json formatter (JSON.NET), but im sure all other libraries have something similiar.
Written by Олег Гаврилов
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#