title: Why does my array need parsing, when they look the same in the console?
body: <p>I'm working on a D3 component when a question springs to mind. As I'm experementing with different arrays, I'm wondering why they need different treatment of data, when they all contain the same.</p>
  
  <p>First case: I have a 'hardcoded' array, which looks like the following:</p>
  
  <pre><code>var tmp = [
      {
          "Weight": 0.0,
          "Speed": 59.9,
          "Depth": 362.24000,
          "Time": "2014-04-09T10:01:23",
          "Id": 0
      }, {
          "Weight": 10.0,
          "Speed": 59.9,
          "Depth": 394.07000,
          "Time": "2014-04-09T10:01:56",
          "Id": 1
      }];
  </code></pre>
  
  <p>Or, when inspected in Chrome console:</p>
  
  <p><img src="https://i.stack.imgur.com/9Frrg.jpg" alt="enter image description here"></p>
  
  <p>Whenever I feed my component with this array, the component works fine and all lines / axis are drawn correctly.</p>
  
  <p>Second case: I fetch an array from my controller using d3.json, and get the following returned when logging it to console:</p>
  
  <pre><code>[{"Weight":0.0,"Speed":59.9,"Depth":362.24000,"Time":"2014-04-09T10:01:23","Id":0},{"Weight":10.0,"Speed":59.9,"Depth":394.07000,"Time":"2014-04-09T10:01:56","Id":1}]
  </code></pre>
  
  <p>So, whenever I'm trying to do a <code>json.foreach()</code> (json is the name of the array from controller):</p>
  
  <pre><code>json.forEach(function(d) {
      var date = format(d.Time);
      d.Time = date;
  });
  </code></pre>
  
  <p>I get an error saying the following when starting the foreach function:
  <code>Uncaught TypeError: undefined is not a function</code>.</p>
  
  <p>In order for this to work, I had to do a <code>JSON.parse(json)</code> on the data returned from my controller through <code>d3.json()</code>, and then my array looks like the following:
  <img src="https://i.stack.imgur.com/W2dM0.jpg" alt="enter image description here"></p>
  
  <p>I should also mention that my asp.net mvc controller returns this:</p>
  
  <pre><code>string json = JsonConvert.SerializeObject(Model.Trend.ToArray());
  
  return Json(json, JsonRequestBehavior.AllowGet);
  </code></pre>
  
  <p>I get the fact that my array returned from controller looks like a string of values when inspecting it, but I really don't understand why.</p>
  
  <p>So, I guess my question really boils down to this;
  Why does my array "tmp" work, but my array fetched with d3.json needs to be parsed before working? </p>