Rather than having two media type formatters (in the latest bits lingo), I wanted to have a single one and have it pick the flavor of Json/Bson on the fly depending on the accept header on the request. This makes configuration simpler as you have to add only one formatter to the pipeline:
var config = HttpHostConfiguration.Create(); config.Configuration.OperationHandlerFactory.Formatters.Insert(0, new JsonNetMediaTypeFormatter());
Even simpler is to use just an extension method over the configuration:
var config = HttpHostConfiguration.Create().UseJsonNet()
Given the simplicity of this class, this doesn’t deserve anything less but being a NETFx NuGet. Go get it or search for WebApi, Json.NET or MediaTypeFormatter in the package library dialog in VS (doesn’t work if you enter multiple words ):
The corresponding unit tests are available too.