title: Adding values from a dictionary to the object's properties when serializing to JSON
body: <p>I  have this model</p>
  
  <pre><code>public class DTO
  {
      public int Id {get;set;}
      public string Name { get; set; }
      public string LastName { get; set; }
  
      public Dictionary&lt;string, string&gt; Items { get; set; }
  }
  </code></pre>
  
  <p>Values in the Dictionary are coming from my database  so they differ from one object to another. Anyway I need to return a Json in specific format in order to be understood by 3rd party grid.
  Example code</p>
  
  <pre><code>    public ActionResult Index()
      {
          DTO dto = new DTO()
          {
              Id = 1 ,
              Name = "Employee1",
              LastName = "last name value",
              Items = new Dictionary&lt;string, string&gt;()
          };
          // properties .....
          dto.Items.Add("Variable 1" , "Value 1 Goes here");
          dto.Items.Add("Variable 2", "Value 2 Goes here");
          dto.Items.Add("Variable 3", "Value 3 Goes here");              
  
          return Json(dto, JsonRequestBehavior.AllowGet);            
      }
  </code></pre>
  
  <p>the desired Json should be like this</p>
  
  <pre><code>{"Id":1, "Name":"Employee1","LastName":"Last Name Value","Variable 1":"Value 1 Goes here","Variable 2":"Value 2 Goes here","Variable 3":"Value 3 Goes here"}
  </code></pre>
  
  <p>Notice <strong>that Dictionary representation MUST not be an array</strong> i.e Converting rows to cols. I've tried a lot using JsonWriter and converters but I could not achieve this result.</p>