title: C# JSON string to JavaScript array
body: <p>I have the following class in C#:</p>
  
  <pre><code>public class Caption
  {
      public string line;
      public string timestamp;
  }
  </code></pre>
  
  <p>I have created some Caption objects and added them to a List:</p>
  
  <pre><code>List&lt;Caption&gt; CaptionList = new List&lt;Caption&gt;();
  var obj = new Caption
  {
    line = "Some text"
    timestamp = "00:10"
  };
  CaptionList.Add(obj);
  </code></pre>
  
  <p>I then use Json.NET to serialize the list to Json, like this:</p>
  
  <pre><code>public string json = JsonConvert.SerializeObject(CaptionList);
  </code></pre>
  
  <p>Now I want to use this as a JavaScript array, so I tried this:</p>
  
  <pre><code>var arr = '&lt;%=json%&gt;';
  </code></pre>
  
  <p>I don't have much JavaScript knowledge, but it seems like <code>arr</code> is now a string and not an array because <code>json</code> is in fact a C# string. I tried accessing the objects by using <code>arr[i].line</code> etc, but that doesn't work. </p>
  
  <p>How do I make the <code>json</code>an actually array in JavaScript?</p>