title: JSON serialization DataContractSerializerOperationBehavior
body: <p>I have a WCF web application (.NET Frameword 4.6.2) which have the following endpoint :</p>
  
  <pre><code>[OperationContract]
  [WebGet(UriTemplate = "Products/{id}")]
  public ProductDTO GetProduct(string id)
  { 
     return Services.GetProduct(id);
  }
  </code></pre>
  
  <p>My DTO has some properties like Name, Price and also a Dictionary of custom properties.</p>
  
  <pre><code>[DataContract­]
  [Serializable]
  public class ProductDTO 
  {
     [DataMember(Name = "Props", IsRequired = true, EmitDefaultValue = false)]
     public IDictionary&lt;string, string&gt; Props {get;set;}
  }
  </code></pre>
  
  <p>I use the default Json serializer from .net to send the response to the client side and the dictionary property is serialized that way :</p>
  
  <pre><code>{
   "Key":"propKey",
   "Value":"propValue"
  }
  </code></pre>
  
  <p>I would like it to be without the keywords "key" and "value". I know we can use  <code>DataContractJsonSerializerSettings</code> to change this setting which is <code>UseSimpleDictionaryFormat</code>. My problem is how can I change this settings for the default framework behaviors for this operation or all my operation contracts? I know I could use Json.Net to fix this use issue, but on short term I'd like to stick with <code>DataContractJsonSerializer</code>. Is there a way I can override a behavior so I can set this setting?</p>
  
  <p>I tried to override the following behavior but it didn't work.</p>
  
  <pre><code>public class DataContractJsonSerializerOperationBehavior : DataContractSerializerOperationBehavior
  {
      public DataContractJsonSerializerOperationBehavior(OperationDescription operation) : base(operation) {}
  
      public DataContractJsonSerializerOperationBehavior(OperationDescription operation, DataContractFormatAttribute dataContractFormatAttribute) : base(operation, dataContractFormatAttribute) {}
  
      public override XmlObjectSerializer CreateSerializer(System.Type type, string name, string ns, IList&lt;System.Type&gt; knownTypes)
      {
          /* Never called */
      }
  
      public override XmlObjectSerializer CreateSerializer(System.Type type, XmlDictionaryString name, XmlDictionaryString ns, IList&lt;System.Type&gt; knownTypes)
      {
          /* Never called */
      }
  }
  </code></pre>
  
  <p>And I also set the behavior for my endpoint:</p>
  
  <pre><code>        foreach (OperationDescription operationDescription in serviceEndpoint.Contract.Operations)
          {
              DataContractSerializerOperationBehavior dataContractBehavior = operationDescription.Behaviors[typeof(DataContractSerializerOperationBehavior)] as DataContractSerializerOperationBehavior;
              if (dataContractBehavior != null)
              {
                  operationDescription.Behaviors.Remove(dataContractBehavior);
                  operationDescription.Behaviors.Add(new DataContractJsonSerializerOperationBehavior(operationDescription));
              }
          }
  </code></pre>