Skip to content

Instantly share code, notes, and snippets.

@jayhjkwon
Last active January 4, 2016 19:29
Show Gist options
  • Save jayhjkwon/8667687 to your computer and use it in GitHub Desktop.
Save jayhjkwon/8667687 to your computer and use it in GitHub Desktop.
Camelcase json serializer for NancyFX
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;
}
}
}
install-package nancy.Serialization.JsonNet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment