title: Get field of C# list of struct from code behind in Javascript
body: <p>I would like to access a <code>List&lt;Records&gt;</code> where Records is a struct, from a JS script. After a bit of googling (especially <a href="https://stackoverflow.com/questions/29098558/asp-net-pass-data-from-code-behind-to-javascript-and-call-array">question 29098558</a> here) i Json serialized my object and retrieve it in the script.</p>
  
  <p>I should mention it's my first time at JS so syntax may be totally wrong.</p>
  
  <p>In C#</p>
  
  <pre><code>  string serializedResults = JsonConvert.SerializeObject(RecordsList);
  </code></pre>
  
  <p>(in my context the records are actually in a <code>Dictionnary&lt;string, Records&gt;</code> but i hide the access through dictionnary because i supposed it isn't relevant here)</p>
  
  <p>In Javascript </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function setupBarChart() {
          var x = [];
          var y = [];
          var source = "&lt;%= serializedRecords %&gt;";
  
          // I would like to put Records fields in y and x tab to use it as data for the axes of an histogram.
          for (var i = 0; i &lt; source.length; i++) {
  
          }  
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>My questions are : </p>
  
  <ul>
  <li>what is the type of source ? Is it just a string ? Does it create an equivalent of List in JS ?</li>
  <li>How do I access my Records fields from JS ?</li>
  <li>Does source.length gives me the number of records in the list ??</li>
  </ul>