#!/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