Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace WCF default JSON serialization

Is it possible to replace the default JSON serialization of WCF (I'm currently testing with the webHttp behaviour), and passing application/json as the MIME type. In particular, I don't like that by default every property is a key/value pair like:

{"Key":"PropertyName", "Value":"PropertyValue"}

I'm using the service only for JSON-enabled endpoints (requesting data with jQuery + WCF).

like image 804
jaraics Avatar asked Jul 22 '11 16:07

jaraics


1 Answers

You can use a message formatter to change the serializer used to deal with JSON. The post at https://docs.microsoft.com/en-us/archive/blogs/carlosfigueira/wcf-extensibility-message-formatters shows an example on how to change the default serializer (DataContractJsonSerializer) to another one (JSON.NET).

like image 66
carlosfigueira Avatar answered Sep 21 '22 17:09

carlosfigueira