Skip to content

Instantly share code, notes, and snippets.

@fernandoacorreia fernandoacorreia/jsonpaths
Last active Jun 30, 2019

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.