title: Converting c# data from entity framework to a valid json type
body: <p>i have below method:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult GetData()
      {
          var data= (dynamic)null;
          using (DBContext context = new DBContext())
          {
              data= context.MyObject.Where(i=&gt; i.TypeId == 1).OrderBy(k =&gt; k.Name).Select(w =&gt; new
              {
                  description = w.Description
              }).ToList();       
          }
  
          return Json(data, JsonRequestBehavior.AllowGet);
      }
  </code></pre>
  
  <p>so I want to convert the data correctly into a json object, but i am not sure if i am doing correctly. This data returned should be used in a javascript.</p>
  
  <p>I have google a lot and i have found example like below, maybe I should do a similar thing, but i do not know how:</p>
  
  <pre><code>var keyValues = new Dictionary&lt;string, string&gt;
                 {
                     { "emailSend", textBox1.Text },
                     { "toEmail", textBox2.Text }
                 };
  
  JavaScriptSerializer js = new JavaScriptSerializer();
  string json = js.Serialize(keyValues);
  MessageBox.Show(json);
  </code></pre>