title: How to return Dictionary<complexType,int> with WebAPI
body: <p>I'm providing a WebApi 2 endpoint that is done in this way:</p>
  
  <p>My controller is simply:</p>
  
  <pre><code> public IDictionary&lt;MyClass, int&gt; GetMyClasses(string id)
   {
      Dictionary&lt;MyClasses, int&gt; sample = new Dictionary&lt;MyClasses, int&gt;();
  
      sample.Add(new MyClasses()
      {
         Property1 = "aaa",
         Property2 = 5,
         Property3 = 8
      },10);
  
      return sample;
   }
  </code></pre>
  
  <p>The structure of MyClass is:</p>
  
  <pre><code>public class MyClass
  {
     string Property1 {get;set;}
     int Property2 {get;set;}
     int Property3 {get;set;}
  }
  </code></pre>
  
  <p>When I run my webservice, the helper webpage shows me that the expected outputs are:</p>
  
  <pre><code>{ "MyNamespace.MyProject.MyClass": 1 }
  </code></pre>
  
  <p>On the other hand the xml sample is what I'd like (except that I want the json, not the xml):</p>
  
  <pre><code>&lt;ArrayOfKeyValueOfMyClassintl85fHlC_P xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"&gt;
    &lt;KeyValueOfMyClassintl85fHlC_P&gt;
      &lt;Key xmlns:d3p1="http://schemas.datacontract.org/2004/07/MyNamespace.MyProject.MyClass"&gt;
        &lt;d3p1:Property1&gt;sample string 4&lt;/d3p1:Property1&gt;
        &lt;d3p1:Property2&gt;8&lt;/d3p1:Property2&gt;
        &lt;d3p1:Property3&gt;5&lt;/d3p1:Property3&gt;
      &lt;/Key&gt;
      &lt;Value&gt;1&lt;/Value&gt;
    &lt;/KeyValueOfMyClassintl85fHlC_P&gt;
  &lt;/ArrayOfKeyValueOfMyClassintl85fHlC_P &gt;
  </code></pre>
  
  <p>I also ran the endpoint with Postman and it confirms that the returned value is the one previewed by the WebApi out of the box page.</p>
  
  <p>Why the json is "wrong" and the xml is well done (I mean that contains all the data)?</p>
  
  <p><strong>UPDATED:</strong></p>
  
  <p>I expected MyClass serialized in json like this:</p>
  
  <pre><code>{
    "Property1": "sample string 4",
    "Property2": 8,
    "Property3": 5
  }
  </code></pre>
  
  <p>This should be the structure of the key of my dictionary, as it is in the xml representation.</p>
  
  <p>Thanks</p>