title: Convert .Net object to JSON object in the view
body: <p>I want to convert a .Net object in to JSON in the view. My view model is like this,</p>
  
  <pre><code>public class ViewModel{
      public SearchResult SearchResult { get; set;}    
  }    
  
  public class SearchResult {
      public int Id { get; set; }
      public string Text{ get; set; }
  }
  </code></pre>
  
  <p>I want to convert <code>Model.SearchResult</code> in to a JSON object. Currenty I'm doing it like this:</p>
  
  <pre><code>System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
  //....
  var s = @serializer.Serialize(Model.Institution);
  </code></pre>
  
  <p>but the result is like this,</p>
  
  <pre><code>var s = { &amp;quot;Name&amp;quot;:&amp;quot;a&amp;quot;,&amp;quot;Id&amp;quot;:1};
  Create:228Uncaught SyntaxError: Unexpected token &amp;
  </code></pre>
  
  <p>How can I convert this correctly in to a JSON object?</p>