title: How do you access an array of Objects using D3?
body: <p>I have a D3 chart where I'm trying to parse an inline JSON formatted array instead of loading the data externally.</p>
  
  <p><strong>Instead of doing something like this:</strong></p>
  
  <pre><code>d3.json("data/tsx.json", function (error, data) {
      data.forEach(function (d) {
          d.dateOrig = d.date;
          d.date = parseDate(d.date);
          d.close = +d.close;
  });
  </code></pre>
  
  <p><strong>I just want to parse an inline JSON formatted array like this:</strong></p>
  
  <pre><code>var data = [
    {"date":"1-May-13","close":58.13},
    {"date":"30-Apr-13","close":53.98},
    {"date":"27-Apr-13","close":67.00},
    {"date":"26-Apr-13","close":89.70},
    {"date":"25-Apr-13","close":99.00},
    {"date":"24-Apr-13","close":130.28},
    {"date":"23-Apr-13","close":166.70},
    {"date":"20-Apr-13","close":234.98},
    {"date":"19-Apr-13","close":345.44},
    {"date":"18-Apr-13","close":443.34},
  ];
  
    data.forEach(function(d) {
      d.date = parseDate(d.date);
      d.close = +d.close;
  </code></pre>
  
  <p><strong>But this doesn't work using the same code I would have used on the first method above.</strong></p>
  
  <p>I've created a Fiddle that sort of works, but I can see that I'm parsing the array wrong and my chart elements are being created multiple times (the same number of times as the length of the array). This does not happen when I load my data externally.</p>
  
  <p>See my comments starting at line 35 in this Fiddle.</p>
  
  <p><a href="http://jsfiddle.net/Critter/Hc7zD/5/" rel="nofollow">http://jsfiddle.net/Critter/Hc7zD/5/</a></p>
  
  <p>How can I rewrite my code to parse the JSON array properly? I'm stumped! Thanks so much!</p>