Skip to content

Instantly share code, notes, and snippets.

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