Last active
January 4, 2016 19:29
-
-
Save jayhjkwon/8667687 to your computer and use it in GitHub Desktop.
Camelcase json serializer for NancyFX
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
namespace NancyApplication1 | |
{ | |
using Nancy; | |
using Nancy.Conventions; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Serialization; | |
public class Bootstrapper : DefaultNancyBootstrapper | |
{ | |
protected override void ConfigureApplicationContainer(Nancy.TinyIoc.TinyIoCContainer container) | |
{ | |
base.ConfigureApplicationContainer(container); | |
container.Register(typeof(JsonSerializer), typeof(CustomJsonSerializer)); | |
} | |
} | |
public class CustomJsonSerializer : JsonSerializer | |
{ | |
public CustomJsonSerializer() | |
{ | |
this.ContractResolver = new CamelCasePropertyNamesContractResolver(); | |
this.Formatting = Formatting.Indented; | |
} | |
} | |
} |
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
install-package nancy.Serialization.JsonNet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment