Giter VIP home page Giter VIP logo

nancy.serialization.jsonnet's Introduction

Implementations of the ISerialization and IBodyDeserializer interfaces, based on Json.NET, for Nancy

Usage

Start of by installing the Nancy.Serialization.JsonNet nuget

When Nancy detects that the JsonNetSerializer and JsonNetBodyDeserializer types are available in the AppDomain, of your application, it will assume you want to use them, rather than the default ones.

Customization

If you want to customize the behavior of Json.NET, you can provide your own implementation of the JsonSerializer type. For example, the following implementation configures Json.NET to use camel-casing and to indent the output

public class CustomJsonSerializer : JsonSerializer
{
    public CustomJsonSerializer()
    {
        this.ContractResolver = new CamelCasePropertyNamesContractResolver();
        this.Formatting = Formatting.Indented;
    }
}

In order for Nancy to know that you want to use the new configuration, you need to register it in your bootstrapper. Here is an example of how you would do that using the DefaultNancyBootstrapper

public class Bootstrapper : DefaultNancyBootstrapper
{
    protected override void ConfigureApplicationContainer(TinyIoCContainer container)
    {
        base.ConfigureApplicationContainer(container);

        container.Register<JsonSerializer, CustomJsonSerializer>();
    }
}

Copyright

Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors

License

Nancy.Serialization.JsonNet is licensed under MIT. Refer to license.txt for more information.

nancy.serialization.jsonnet's People

Contributors

thecodejunkie avatar grumpydev avatar khellang avatar jchannon avatar emilcardell avatar vbfox avatar clempi avatar jskimming avatar phillip-haydon avatar purekrome avatar rasmus-beck avatar codeprogression avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.