-
-
Save c3ph3us/6518399816cd718db21e7a22b647121a to your computer and use it in GitHub Desktop.
A collection of tools for working with JS and JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:<<'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