Created
June 29, 2017 14:19
-
-
Save deepumi/66ca36924eacd8c46ef24e9654abea60 to your computer and use it in GitHub Desktop.
Json configuration for web api camel case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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