5

I am developing a very simply WebAPI in .Net 4.6. WebAPI, by default use JSON.Net as JSON serializer. For this application, I am willing to set default JSON serializer to NewtonSoft JSON.

Please help me how I can do this.

Ranjan Kumar
  • 457
  • 1
  • 6
  • 21

1 Answers1

16
var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
    formatter.SerializerSettings = new JsonSerializerSettings
    {
        Formatting = Formatting.Indented,
        TypeNameHandling = TypeNameHandling.Objects,
        ContractResolver = new CamelCasePropertyNamesContractResolver()
    };

Would be placed in your global.asax

DShorty
  • 582
  • 1
  • 5
  • 13