title: Serialize .NET Dictionary<string, string> into JSON Key Value Pair Object
body: <p>I need to get:</p>
  
  <pre><code>public class Package
  {
      public Package()
      {
          name = "";
          type = new List&lt;Dictionary&lt;string, string&gt;&gt;();
      }
  
      public string name { get; set; }
      public List&lt;Dictionary&lt;string, string&gt;&gt; type { get; set; }
  }
  </code></pre>
  
  <p>into:</p>
  
  <pre><code>{
      "name":"package_name",
      "type":
      {
          "http://random.url.as.key":"random/value"
      }
  }
  </code></pre>
  
  <p>with:</p>
  
  <pre><code>Package package = new Package();
  package.name = "package_name";
  package.type.Add(new Dictionary&lt;string, string&gt;() { { "http://random.url.as.key", "random/value" } });
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>{
      "name":"package_name",
      "type":
      [
          [
              {
                  "Key":"http:\/\/random.url.as.key",
                  "Value":"random\/value"
              }
          ]
      ]
  }
  </code></pre>
  
  <p>while, with:</p>
  
  <pre><code>var package = new
  {
      name = "package_name",
      type = new
      {
          http_random_url_as_key = "random/value"
      }
  };
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>{
      "name":"package_name",
      "type":
      {
          "http_random_url_as_key":"random/value"
      }
  }
  </code></pre>
  
  <p>I can't get the obsure <em>http://random.url.as.key</em> that I need. I have tried using JavaScriptSerializer, DataContractJsonSerializer, <em>and</em> Custom Convertor for Json.NET, all with limited success/shortcomings.</p>
  
  <p>There must be a better way/something I'm overlooking to get a simple JSON Object over the wire!</p>