Last active
          August 17, 2023 15:49 
        
      - 
      
- 
        Save RichardBronosky/81a3991aa63580283bf2f3db18ecf2fb to your computer and use it in GitHub Desktop. 
    A collection of tools for working with JS and JSON
  
        
  
    
      This file contains hidden or 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