Notepad
2019-06-11 Edit

Sometimes you want to filter a json and only take a part of it.

Let’s say you have this json:

{
   "list":[
      {
         "a":"b",
         "c":"d",
         "e": "f"
      },
      {
         "a":"g",
         "c":"h",
         "e": "i"
      },
      {
         "a":"b",
         "c":"d",
         "e": "i"
      }
   ]
}

You only want the objects where the key a had the value "b". You are not interested in the key c, you only want the key e.

You can achieve this by using the jq expression: .list[] | {a, e} | select(.a == "b")

The result is

{
  "a": "b",
  "e": "f"
}
{
  "a": "b",
  "e": "i"
}

You can play and adapt the json to your reality in jq playground