Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Last active August 17, 2023 15:49
Show Gist options
  • Save RichardBronosky/81a3991aa63580283bf2f3db18ecf2fb to your computer and use it in GitHub Desktop.
Save RichardBronosky/81a3991aa63580283bf2f3db18ecf2fb to your computer and use it in GitHub Desktop.
A collection of tools for working with JS and JSON
:<<'DOCS'
* This script adds to your bash shell, a collection of tools for working with JS and JSON
* To install it, cd to where ever you checkout git repos and copy-paste the following line:
dst=jtools; git clone https://gist.github.com/81a3991aa63580283bf2f3db18ecf2fb.git $dst && echo -e "\n[[ -f $(dirs +0)/$dst/source.bash ]] && source $(dirs +0)/$dst/source.bash" >> ~/.bash_profile
DOCS
# converts serialized python to JSON
p2j() { python3 -c "import json, sys; print(json.dumps(eval(sys.stdin.read())))"; }
# pretty prints JSON with nested/embedded escaped/encoded JSON in it
jqp(){ jq 'walk(
if type == "string" then
if tonumber? // false then
.
else
fromjson? // .
end
else
.
end
)' "$@"; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment