Using Json.Net as the Serializer for REST and AJAX Callbacks

West Wind Web Toolkit includes default serialization services using the WestWindJsonSerializer class. However, if you prefer you can also use the popular Json.Net serializer.

To do this:

  • Add the Json.Net assembly to your project
  • Hookup Json.Net as your default JSON serializer

Add Json.Net to your Project

The easiest way to add Json.Net is to add it via NuGet by using NuGet Package Manager and installing with:

PM> Install-Package Newtonsoft.Json

Set Json.Net as your default JSON Serializer

To set up JSON .NET as your default serializer, simply set a global flag in your application's startup code so it only fires once. The following code works in Application_Start of an ASP.NET application:

protected void Application_Start(object sender, EventArgs e)
    JSONSerializer.DefaultJsonParserType = SupportedJsonParserTypes.JsonNet;

Once set, all JSON serialization automatically will use the Json.Net serializer.

© West Wind Technologies, 1996-2016 • Updated: 04/15/13
Comment or report problem with topic