title: JQ error: is not defined at <top-level> when trying to add values to jq template
body: <p>I have a .jq template that I want to update values under the samples list, formatted as:</p>
  
  <pre><code>{
    "test": "abc",
    "p": "1",
    "v": "1.0.0",
    "samples": [
      {
        "uptime": $uptime,
        "curr_connections": $curr_connections,
        "listen_disabled_num": $listen_disabled_num,
        "conn_yields": $conn_yields,
        "cmd_get": $cmd_get,
        "cmd_set": $cmd_set,
        "bytes_read": $bytes_read,
        "bytes_written": $bytes_writtem,
        "get_hits": $get_hits,
        "rejected_connections": $rejected_connections,
        "limit_maxbytes": $limit_maxbytes,
        "cmd_flush": $cmd_flush
      }
    ]
  }
  </code></pre>
  
  <p>My shell script to do this is below, I am basically running a command to pull some memcached output stats and want to insert some of the results into the jq template as key/values.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>JQ=`cat template.jq`
  
  SAMPLES=(uptime curr_connections listen_disabled_num conn_yields cmd_get cmd_set cmd_flush bytes_read bytes_written get_hits rejected_connections limit_maxbytes)
  
  for metric in ${SAMPLES[*]}
  do
    KEY=$(echo stats | nc $HOST $PORT | grep $metric | awk '{print $2}')
    VALUE=$(echo stats | nc $HOST $PORT | grep $metric | awk '{print $3}')
  
    echo "Using KEY: $KEY with value: $VALUE"
  
    jq -n --argjson $KEY $VALUE -f template.jq
  done</code></pre>
  </div>
  </div>
  </p>
  
  <p>Not sure if this is the best way to handle this scenario, but I am getting a ton of errors such as: </p>
  
  <pre><code>jq: error: conn_yields/0 is not defined at &lt;top-level&gt;, line 12:
        "conn_yields": $conn_yields,
  jq: error: cmd_get/0 is not defined at &lt;top-level&gt;, line 13:
        "cmd_get": $cmd_get,
  jq: error: cmd_set/0 is not defined at &lt;top-level&gt;, line 14:
        "cmd_set": $cmd_set,
  </code></pre>