Skip to content

Instantly share code, notes, and snippets.

@edygert
Last active May 6, 2023 14:09
Show Gist options
  • Save edygert/41168ca957fa4cc8660a54ae5e8889e0 to your computer and use it in GitHub Desktop.
Save edygert/41168ca957fa4cc8660a54ae5e8889e0 to your computer and use it in GitHub Desktop.
jq script to show the schema of a JSON file
paths
| join(".")
| select(test("[.][1-9][0-9]*[.|$]?") | not)
| gsub("[.]0[.]"; "[].")
| sub("[.]0$"; "[]")
| sub("^"; ".")
@edygert
Copy link
Author

edygert commented May 6, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment