title: How to use jq to create an object with an arbitrary key from a sub array?
body: <p>Please feel free to edit the title, I am not sure how to best express it :).</p>
  
  <p>I have JSON that, for example, looks like this: </p>
  
  <pre><code>{
    "things": [
       {
          "name": "foo",
          "params": [
             {
               "type": "t1",
                "key": "key1",
                "value": "val1"
             },
             {
                "type": "t1",
                "key": "category",
                "value": "thefoocategory"
             }
          ]
        },
        {
          "name": "bar",
          "params": [
             {
               "type": "t1",
               "key": "key1",
               "value": "val1"
             },
             {
               "type": "t1",
               "key": "category",
               "value": "thebarcategory"
             }
          ]
       }
    ]
  }
  </code></pre>
  
  <p>What I am trying to achieve is output that looks like</p>
  
  <pre><code>[
    {
      name: "foo",
      category: "thefoocategory"
    },
    {
      name: "bar",
      category: "thebarcategory"
    }
  ]
  </code></pre>
  
  <p>I am able to extract the names quite easily with <code>jq ' .things | .[] | .name'</code></p>
  
  <p>I can also extract the categories with <code>jq ' .things | .[] | .params | .[] | select(.key == "category") | .value'</code></p>
  
  <p>But I have not been able to combine them.</p>
  
  <p>Any help appreciated</p>