3 ms·
i have 2 letters for you: jq any tool that outputs json + jq => instant scriptability win.
by rantwasp 7y ago
i have 2 letters for you: jq
any tool that outputs json + jq => instant scriptability win.
- technofiend 7y agoParticularly if you prepend queries with try. jq likes to throw errors when unexpected things happen in your search or your data, and it may return "null". Using try instead returns an empty string. When walking JSON structures to validate data I code each validation separately instead of burying them in blocks of if-then-else logic. I think this makes it easier to maintain and more obvious when dealing with data that for example may be in a list or an array of lists. But yeah if you write golang scripts and want to shuffle data in and out of bash, jq is your #1 power tool.
- de_watcher 7y agoTwo letters, but then several lines to write an actual simple request (with some dances to battle the null and the exit code), and it's slow.