Is there any way to replace the WCF service application built-in JavascriptSerializer with Newtonsoft Json.Net json serializer?
Asked
Active
Viewed 2.1k times
1 Answers
17
WCF doesn't use JavascriptSerializer
. It uses DataContractJsonSerializer. And yes, you can replace it with Json.NET by writing a custom message formatter as exemplified in the following blog post.

Igor
- 349
- 1
- 6

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
-
2because DataContractJsonSerializer is much slower than Json.NET. – iNc0ming Jun 22 '12 at 11:03
-
Is this a question that you are asking? Is there something else you would like to ask? – Darin Dimitrov Jun 22 '12 at 11:59
-
ok, the question is going further now. According to this article - http://code.msdn.microsoft.com/windowsdesktop/Supporting-different-data-b0351c9a, I have made a custom DispatchFormatter, but how to register it to the wcf service application via web.config? – iNc0ming Jun 22 '12 at 12:33
-
You could write a custom `IServiceBehavior` to apply the message formatter globally to the service. – Darin Dimitrov Jun 22 '12 at 12:53
-
By following this article - [link](http://stackoverflow.com/questions/8082231/custom-behavior-wont-register-in-my-web-config), all works now, thank u guys for help. – iNc0ming Jun 22 '12 at 13:34