title: CSV to JSON using jq
body: <p>If you have a csv dataset like this:</p>
  <pre><code>name, age, gender
  john, 20, male
  jane, 30, female
  bob, 25, male
  </code></pre>
  <p>Can you get to this:</p>
  <pre><code>[ {&quot;name&quot;: &quot;john&quot;, &quot;age&quot;: 20, &quot;gender&quot;: &quot;male&quot;},
    {&quot;name&quot;: &quot;jane&quot;, &quot;age&quot;: 30, &quot;gender&quot;: &quot;female&quot;},
    {&quot;name&quot;: &quot;bob&quot;, &quot;age&quot;: 25, &quot;gender&quot;: &quot;male&quot;} ]
  </code></pre>
  <p>using only jq?</p>
  <p>I found <a href="http://infiniteundo.com/post/99336704013/convert-csv-to-json-with-jq" rel="noreferrer">this</a> article which shows what I'm trying to do, but it uses a 'manual' mapping of the header fields to the values.  I don't need/want to rename the header fields and have quite a few of them.  I would also not want to have to change a script/command every time the layout changes.</p>
  <p>Is it possible to dynamically extract the headers and then combine them with the values with a jq one-liner?</p>