JQ: exclude specified built-in keys

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 named "key_x" , so the result should be

 { "key1": { ... "key_z": "2" }, "key2": { ... "key_z": "3" } } 
+5
source share
1 answer

You can use the del() function:

 jq 'del(.[]|.key_x)' input.json 
+4
source

Source: https://habr.com/ru/post/1236429/


All Articles