title: D3 how to properly get the key value INSIDE of a json object
body: <p>I am trying to generate my column headers based on the key value of the returned json object. However it is returning as <code>[0,1]</code> rather than <code>[key[1],key[2]]</code>. </p>
  
  <p>This is my json data and I'm trying to use D3 to get the key's of this object (which is "Label", "Count" for example) as my column headers rather than inserting it statically. </p>
  
  <pre><code>[
    {
    "Label": "External-Partner-Induced",
    "Count": 9
    },
  {
   "Label": "Null",
   "Count": 1
  },
  {
   "Label": "FCTS-Induced",
   "Count": 66
  },
  {
   "Label": "EI-Partner-Induced",
   "Count": 78
   }
  ]
  </code></pre>
  
  <p>Here is my d3 code:</p>
  
  <pre><code>d3.json('dataQualityIssuesCategory.json', function (error,data) {
  
      function tabulate(data, columns) {
      var table = d3.select('body').append('table')
      var thead = table.append('thead')
      var tbody = table.append('tbody');
  
      // append the header row
      thead.append('tr')
        .selectAll('th')
        .data(columns).enter()
        .append('th')
          .text(function (column) { return column; });
  
      // create a row for each object in the data
      var rows = tbody.selectAll('tr')
        .data(data)
        .enter()
        .append('tr');
  
  
     // create a cell in each row for each column
      var cells = rows.selectAll('td')
        .data(function (row) {
          return columns.map(function (column) {
            return {column: column, value: row[column]};
          });
        })
        .enter()
        .append('td')
          .text(function (d) { return d.value; });
       return table;
       }
  
      // render the table
      tabulate(data, [d3.keys(data)[0], d3.keys(data)[1]]); // 2 column table
  });
  </code></pre>
  
  <p>The tabulate function is where I am trying to get my key fields for the column headers but the code above seems to be getting the entire object instead of the  value INSIDE. Example: <code>[0,1]</code> as column headers instead of <code>[Label, Count]</code> <a href="https://i.stack.imgur.com/JDvXM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JDvXM.png" alt="example"></a>: </p>