Created
January 5, 2015 19:08
-
-
Save GeoffCox/0d66e904de35f993b89e to your computer and use it in GitHub Desktop.
Use camel case for MVC web-API
This file contains hidden or 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
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