title: MVC List to jquery
body: <p>I am having an issue pushing a list from my C# model in razor to jquery to play with!</p>
  
  <p>So assume my List is working well and I am able to see the data in razor <em>(Because I can)</em></p>
  
  <p>I then have the following:</p>
  
  <pre><code>@using Models.DatabaseModel;
  @using Newtonsoft.Json;
  @{
      Person _Person = ViewBag._Person;
      var json = JsonConvert.SerializeObject(new
      {
          operations = _Person
      });
   }
  </code></pre>
  
  <p>And then at the bottom I have a javascript loading as so:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
          $(document).ready(function () {
              StoreUserInfo("@json");
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>The following calls the javascript correctly, but the string that is passed through to the javascript is full of html characters</p>
  
  <p>An example: <strong>"{&quot;operations&quot;:{&quot;PersonID&quot;:"8"}}"</strong></p>
  
  <p>My jquery is as follows:</p>
  
  <pre><code>function StoreUserInfo(UserObject)
  {
      var jsonobj = $.parseJSON(UserObject);
      if (typeof (Storage) !== "undefined") {
  
      } else {
  
      }
  
  }
  </code></pre>
  
  <p>Which errors with the Syntax Error:</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected token &amp; in JSON at position 1</p>
  </blockquote>
  
  <p>The theory behind this is my C# list pushes a heap of data that I want to store in local storage, I am open to a better method to do this if anyone has it or solutions to my syntax issue I am having.</p>