title: How to Iterate over an array of objets using jq
body: <p>I have a javascript file which prints a JSON array of objects:</p>
  <pre class="lang-json prettyprint-override"><code>// myfile.js output
  [
    { &quot;id&quot;: 1, &quot;name&quot;: &quot;blah blah&quot;, ... },
    { &quot;id&quot;: 2, &quot;name&quot;: &quot;xxx&quot;, ... },
    ...
  ]
  </code></pre>
  <p>In my bash script, I want to iterate through each object.</p>
  <p>I've tried following, but it doesn't work.</p>
  <pre class="lang-sh prettyprint-override"><code>#!/bin/bash
  
  output=$(myfile.js)
  for row in $(echo ${output} | jq -c '.[]'); do
    echo $row
  done
  </code></pre>