jq ' from_entries '

cat data/ann.json | jq ' .metadata.annotations | to_entries | map(select(.key | test("label[1-9]"))) ' cat data/ann.json | jq ' .metadata.annotations | to_entries | map(select(.key | test("label[1-9]"))) | from_entries '
[
  {
    "key": "label1",
    "value": "stam"
  },
  {
    "key": "label2",
    "value": "another"
  },
  {
    "key": "label3",
    "value": "one"
  }
]
    
{
  "label1": "stam",
  "label2": "another",
  "label3": "one"
}