title: How to set Json.Net as the default serializer for WCF REST service
body: <p>Is it possible to override the default WCF DataContractSerializer behaviour when Serialize/DeSerialize entities and use JSON.NET instead?</p>
  
  <p>I have the following service contract for handling the City entity. For design reasons the City entity has IsReference=true, and therefore the default DataContractSerializer raise errors.</p>
  
  <p>For the "GET" methods I can handle the situation with JsonConvert.DeserializeObject, but with "PUT,POST,DELETE" methods DataContractSerializer takes precedence and fails complaining for the IsReference entities cannot be serialized. </p>
  
  <p>I have find this <a href="http://www.pluralsight-training.net/community/blogs/aaron/archive/2006/04/21/22284.aspx" rel="noreferrer">Post</a> to implement IOperationBehavior and provide my own Serializer but I do not know how to integrate Json.NET with this. and I believe there should be more straight forward approach for this. </p>
  
  <p>I’d appreciate any help or guidance regarding this scenario, or advice to other approaches.</p>
  
  <pre><code>[ServiceContract]
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
  public class CityService
  {
      [Description("Get all Cities")]  
      [WebGet(UriTemplate = "")]
      public Message Cities()
      {
  
      }
  
      [Description("Allows the details of a single City to be updated.")]
      [WebInvoke(UriTemplate = "{code}", Method = "PUT")]
      public Message UpdateCity(string code, City city)
      {
      }
  }
  </code></pre>
  
  <p>Many thanks</p>
  
  <p>Hossam</p>