title: Discovery's Weird JSON, SQL Server, and OPENJSON
body: <p>I am using an API from Discovery to extract some information from our virtual machines but the JSON for some reasons have the headings in one node and the values in another and they are in square brackets and I am having a hard getting to the end result.</p>
  <p>This is a watered-down version of the JSON</p>
  <pre><code>DECLARE @JSON nvarchar(max) = N'[
      {
          &quot;headings&quot;: [
              &quot;vm_type&quot;,
              &quot;Hostname&quot;
              ],
          &quot;results&quot;: [
              [
                  &quot;AWS EC2 Instance&quot;,
                  null
              ],
              [
                  &quot;AWS EC2 Instance&quot;,
                  null
              ]
          ]
      }
  ]'
  
  SET @JSON = SUBSTRING(@JSON,2,LEN(@JSON) - 2)
  SELECT *
  FROM OPENJSON(@JSON)
  
  SELECT *
  FROM OPENJSON(@JSON,'$.results')
  </code></pre>
  <p>Is there a way to turn this into a table with the headings as column names and the results in the same order as its value?</p>