Created
February 18, 2026 14:33
-
-
Save deas/a4c47809bbee6d633e05d938a8b31b2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| depth=$1 | |
| jq 'def scrub(n): | |
| if type == "object" then | |
| if n == 0 then empty | |
| else map_values(scrub(n - 1)) | with_entries(select(.value != null)) | |
| end | |
| elif type == "array" then | |
| if n == 0 then empty | |
| else map(scrub(n - 1)) | |
| end | |
| else . | |
| end; | |
| scrub('"${depth}"')' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment