JQ JSON processor - 01-30-20

One of my oldest snippets is how to Pretty print JSON in the shell. This method works great for simple things where you just need to get an idea of the JSON structure, it has the bonus of using python which you probably already have installed. The problem is when you want to do more complex tasks it is quite limited in terms of parsing. Thats where jq comes in

$ curl https://review-noticket-xxxxxxxx.eu/xxxxx/static/loadable-stats.json  | jq '.entrypoints .sharedHeader .assets' | rg --invert-match map`

Simply piping to jq pretty prints the JSON but by passing a query string, ex ".entrypoints .sharedHeader .assets”, you dig into the JSON and easily get what you need. This is easily combinable with other shell utilities like in the example above which gets a list of asset URLs than uses ripgrep invert-match to clean out the source map URLs from the list. This is now my perfered way of working with JSON in the shell.


\- [ JSON, curl, jq ]