title: JSON deserialize with nested list in C#
body: <p>I am serializing and deserializing a Dictionary in C#. My data structure is:</p>
  
  <pre><code>    public class DataField
  {
      private string _Name;
      public string Name
      {
          get { return _Name; }
          set
          {
              _Name = value;
          }
      }
  
      private string _Label;
      public string Label
      {
          get { return _Label; }
          set
          {
              _Label = value;
          }
      }
  
      private ControlType _TypeOfControl;
      public ControlType TypeOfControl
      {
          get { return _TypeOfControl; }
          set { _TypeOfControl = value; }
      }
  
      private int _Width;
      public int Width
      {
          get { return _Width; }
          set
          {
              _Width = value;
          }
      }
      private DataType _DataType;
      public DataType DataType
      {
          get { return _DataType; }
          set { _DataType = value; }
      }
  
      private Control _ControlAccessor;
      public Control ControlAccessor
      {
          get { return _ControlAccessor; }
          set { _ControlAccessor = value; }
      }
  
  
      private Type _ControlType;
      public Type ControlType
      {
          get { return _ControlType; }
          set { _ControlType = value; }
      }
  
      private List&lt;KeyValuePair&lt;string, string&gt;&gt; _Items;
      public List&lt;KeyValuePair&lt;string, string&gt;&gt; Items
      {
          get { if (_Items == null) _Items = new List&lt;KeyValuePair&lt;string, string&gt;&gt;(); return _Items; }
          set { _Items = value; }
      }
  </code></pre>
  
  <p>The object I am serializing is <code>Dictionary&lt;string, DataField&gt;()</code>. I am doing:</p>
  
  <pre><code>JavaScriptSerializer js = new JavaScriptSerializer();
  string str = js.Serialize(ht);`
  </code></pre>
  
  <p>The string I get is correct:</p>
  
  <pre><code>{"Title" {"Name":"Title","Label":null,"TypeOfControl":0,"Width":200,"DataType":0,"ControlAccessor":null,"ControlType":null,"Items":[]}
  ,"Price":{"Name":"Price","Label":null,"TypeOfControl":0,"Width":100,"DataType":1,"ControlAccessor":null,"ControlType":null,"Items":[]}
  ,"Category":{"Name":"Category","Label":null,"TypeOfControl":0,"Width":100,"DataType":1,"ControlAccessor":null,"ControlType":null,"Items":[]}
  ,"Test":{"Name":"Test","Label":null,"TypeOfControl":0,"Width":100,"DataType":1,"ControlAccessor":null,"ControlType":null,"Items":[]}
  ,radioGeo":{"Name":"radioGeo","Label":null,"TypeOfControl":3,"Width":0,"DataType":0,"ControlAccessor":null,"ControlType":null
  ,"Items":[{"Key":"Position","Value":"posit"},{"Key":"Area","Value":"area"},{"Key":"Area","Value":"area"}]}
  ,"htmled":{"Name":"htmled","Label":null,"TypeOfControl":2,"Width":170,"DataType":0,"ControlAccessor":null,"ControlType":null,"Items":[]}}";
  </code></pre>
  
  <p>When I deserialize it, ALMOST everything is correct. The problem is the nested lists. While they serialize fine, the list is empty when I put it back to together.</p>
  
  <p>Any suggestions?</p>