Using jq to compare two fields from same json and printing some other field as a result

Viewed 4099

I have json data in following format

{
  "body": [
    {
      "username": "name1",
      "id": "4444"
    },
    {
      "username": "name2",
      "id": "5555"
    }
  ],
  "meta": {
    "input": "name1"
  }}

Given this data I want to match the "username"s in the body with "meta.input" and if there is a match return/print related id.

2 Answers
Related