22

From the following input:

{
    "key1": {
        "key_x": "1",
        ...
        "key_z": "2"
    },
    "key2": {
        "key_x": "2",
        ...
        "key_z": "3"
    }
}

I would like to exclude all keys with the name "key_x" so the result should be

{
    "key1": {
        ...
        "key_z": "2"
    },
    "key2": {
        ...
        "key_z": "3"
    }
}
peak
  • 105,803
  • 17
  • 152
  • 177
Nic
  • 371
  • 2
  • 3
  • 8

1 Answers1

27

You can use the del() function:

jq 'del(.[]|.key_x)' input.json
hek2mgl
  • 152,036
  • 28
  • 249
  • 266