Skip to content

Instantly share code, notes, and snippets.

@NotFounds
Last active January 23, 2024 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NotFounds/444d26b47c56488b60c138b2fbee5bfb to your computer and use it in GitHub Desktop.
Save NotFounds/444d26b47c56488b60c138b2fbee5bfb to your computer and use it in GitHub Desktop.
A script to interactively narrow down JSON Paths from a JSON file.
function jpath() {
local JSONFILE=$1
local _paths=$(jq -cr 'paths | map(if type=="number" then "[" + tostring + "]" else "." + tostring end) | join("")' $JSONFILE)
local _path=$(echo "$_paths" | fzf --preview "echo {} | xargs -I path jq 'path' $JSONFILE")
echo "$_path"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment