Last active
May 6, 2023 14:09
-
-
Save edygert/41168ca957fa4cc8660a54ae5e8889e0 to your computer and use it in GitHub Desktop.
jq script to show the schema of a JSON file
This file contains 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
paths | |
| join(".") | |
| select(test("[.][1-9][0-9]*[.|$]?") | not) | |
| gsub("[.]0[.]"; "[].") | |
| sub("[.]0$"; "[]") | |
| sub("^"; ".") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses paths to extract all the paths, removes all array entries above 0 because they add no new information, then formats the final output so that you can copy/paste the full path of any field.