title: How do i add an index in jq
body: <p>I want to use jq map my input</p>
  
  <pre><code>["a", "b"]
  </code></pre>
  
  <p>to output</p>
  
  <pre><code>[{name: "a", index: 0}, {name: "b", index: 1}]
  </code></pre>
  
  <p>I got as far as </p>
  
  <pre><code>0 as $i | def incr: $i = $i + 1; [.[] | {name:., index:incr}]'
  </code></pre>
  
  <p>which outputs:</p>
  
  <pre><code>[
    {
      "name": "a",
      "index": 1
    },
    {
      "name": "b",
      "index": 1
    }
  ]
  </code></pre>
  
  <p>But I'm missing something.</p>
  
  <p>Any ideas?</p>