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
  • 497
  • 2
  • 8
  • 24

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.cs file.

bwegs
  • 3,769
  • 2
  • 30
  • 33
DShorty
  • 582
  • 1
  • 6
  • 14