Last active
November 5, 2024 16:18
-
-
Save fernandoacorreia/4b67a41bbe227654868df5eb3ca311d7 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# | |
# Outputs JSON paths. | |
# | |
# Based on https://news.ycombinator.com/item?id=20264654 | |
# | |
# Usage: | |
# curl -s https://raw.githubusercontent.com/sitepoint-editors/json-examples/master/src/db.json | ./jsonpaths | |
jq -r --stream ' | |
select(length > 1) | |
| ( | |
.[0] | map( | |
if type == "number" | |
then "[" + tostring + "]" | |
else "." + . | |
end | |
) | add | |
) + " = " + (.[1] | @json) | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment