Search code examples
c#.net-corenancy

Nancy 2.0.0-barneyrubble JSON retain casing


enter image description hereAm trying to get Nancy to retain property names as they are. For example FirstName to remain so instead of firstName in Response.AsJson. I have seen where it is mentioned to set JsonSettings.RetainCasing = true. I couldn't find it in Nancy.Json or an example where to set this configuration. Any hint where to find this setting and where to place it?


Solution

  • By default Nancy uses SimpleJson. To configure case retaining just override the configure method like this :

        public class MyBootstrapper : DefaultNancyBootstrapper
        {
            public override void Configure(INancyEnvironment environment)
            {
                environment.Json(retainCasing: true);
                base.Configure(environment);
            }
        }