title: Serializing a class containing a Dictionary of Dictionay
body: <p>I have defined a class which contains only one member of type dictionary of dictionary. I want to serialize it to <code>JSON</code> format and hence using <code>JavaScriptSerializer</code>.</p>
  
  <pre><code>[Serializable]
  class X
  {
      private readonly Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt; dic;
  
      public X()
      {
          dic = new Dictionary&lt;string, Dictionary&lt;string, string&gt;&gt;();
      }
  
      public void Add()
      {
          this.dic.Add("x", new Dictionary&lt;string, string&gt;() { { "a", "b" } });
      }
  }
  
  
  class Program
  {
      static void Main(string[] args)
      {
          var x = new X();
          x.Add();
          string msg = new JavaScriptSerializer(new SimpleTypeResolver()).Serialize(x);
          var y = new JavaScriptSerializer(new SimpleTypeResolver()).Deserialize&lt;X&gt;(msg);
      }
  }
  </code></pre>
  
  <p>Now, the above code run successful without any error/exception but the results are not as excepted. The serialized string of class X in the above code is </p>
  
  <pre><code>{"__type":"Testing.X, Testing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}
  </code></pre>
  
  <p>Can anybody tell me whats the problem in the above code and what I'm missing? Also, if in the above class, I change the inner dictionary type to <code>Dictionary&lt;string, IEntity&gt;</code> then what all I have to do to serialize it.</p>