Skip to content

Instantly share code, notes, and snippets.

@GeoffCox
Created January 5, 2015 19:08
Show Gist options
  • Save GeoffCox/0d66e904de35f993b89e to your computer and use it in GitHub Desktop.
Save GeoffCox/0d66e904de35f993b89e to your computer and use it in GitHub Desktop.
Use camel case for MVC web-API
private static void SetJsonSerializerDefaults()
{
// I set the default JSON setting to provide camel-cased properties
JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
// I set the web API serializer for JSON to use JsonConverts default settings
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = JsonConvert.DefaultSettings();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment