Skip to content

Instantly share code, notes, and snippets.

@deepumi
Created June 29, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepumi/66ca36924eacd8c46ef24e9654abea60 to your computer and use it in GitHub Desktop.
Save deepumi/66ca36924eacd8c46ef24e9654abea60 to your computer and use it in GitHub Desktop.
Json configuration for web api camel case
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Json settings
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment