Last active
August 16, 2024 14:02
-
-
Save AlexNolasco/f68994d98e37b0658caf1fdef4fbb1aa to your computer and use it in GitHub Desktop.
quick and dirty json convert int and nulls to strings
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
| jq 'def walk(f): . as $in | if type == "object" then reduce keys[] as $key ({}; . + {($key): ($in[$key] | walk(f))}) elif type == "array" then map(walk(f)) else f end; walk(if . == null then "null" elif type == "number" then tostring else . end)' ./Untitled-10.json | |
| or | |
| cat input.json | jq 'def walk(f): . as $in | if type == "object" then reduce keys[] as $key ({}; . + {($key): ($in[$key] | walk(f))}) elif type == "array" then map(walk(f)) else f end; walk(if . == null then "null" elif type == "number" then tostring else . end)' | |
| or | |
| jq 'def walk(f): . as $in | |
| | if type == "object" then | |
| reduce keys[] as $key ({}; . + {($key): ($in[$key] | walk(f))}) | |
| elif type == "array" then | |
| map(walk(f)) | |
| else | |
| f | |
| end; | |
| walk(if . == null then "null" | |
| elif type == "number" then tostring | |
| else . | |
| end)' input.json > output.json |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unextract parameters