Tawani
Tawani

Reputation: 11198

C# WCF REST - How do you use JSON.Net serializer instead of the default DataContractSerializer?

In .NET 3.5, Is it possible to override the default DataContractJsonSerializer and use the JSON.net serializer instead?

NOTE: We do not want to use attributes on the class

Upvotes: 2

Views: 8261

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87228

Yes, it's possible to do so. But it's not too simple. You'll need a new message formatter which uses the JSON.NET serializer instead of the default one to convert between the operation parameters and the message object needed by the WCF stack. The post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/05/03/wcf-extensibility-message-formatters.aspx has an example that does exactly that. The code is written for 4.0, but it should work for 3.5 as well.

Upvotes: 3

Related Questions