In this article I give a quick snapshot of what it’s like to work with JSON in various traditional and next generation shells. Traditional shells like Bash and Windows Command Prompt (cmd.exe) don’t have built-in JSON support and require 3rd party utilities. Newer shells like NGS, Nushell, Oil, Elvish, Murex, and PowerShell have JSON serialization/deserialization and filtering capabilities built-in for a cleaner experience.
Use a jc Output and/or Serializer Module to parse the output of commands run on Saltstack Minions.
Use the jc community.general Ansible filter plugin to parse the output of commands run on remote hosts.
jello works similarly to jq but uses the python interpreter, so you can iterate with loops, comprehensions, variables, expressions, etc. just like you would in a full-fledged python script.
jtbl is simple and elegant. It just takes in piped JSON or JSON Lines data and prints a table. There’s only one option to turn on column truncation vs. wrapping columns if the terminal width is too narrow to display the complete table. It ‘does the right thing’.
Do one thing well. For command-line utilities to do their one thing “well” they must include standardized machine-readable output. Linux and all of its supporting GNU and non-GNU utilities should offer JSON output options.