Calendars, SSH keys, and messy spreadsheet exports are easy to read by eye but a pain to script against. In Part 3 of JC Tips and Tricks, we turn .ics files, authorized_keys files, and headerless CSV/TSV files into clean JSON you can query with jq.
Tag Archives: linux
JC Tips and Tricks – Part 2
Tips and tricks for using JC interactively, in scripts, and in automation.
In Part 2 we look at using JC to parse URLs, POSIX paths, and git log output.
JC Tips and Tricks – Part 1
Tips and tricks for using JC interactively, in scripts, and in automation.
In Part 1 we look at using JC as a Subnet Calculator, for exploring X.509 certificates, and for converting dates and timestamps.
Working with JSON in Various Shells
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.
Parsing Command Output in Saltstack with JC
Use a jc Output and/or Serializer Module to parse the output of commands run on Saltstack Minions.
Parsing Command Output in Ansible with JC
Use the jc community.general Ansible filter plugin to parse the output of commands run on remote hosts.
Jello: The JQ Alternative for Pythonistas
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.
JSON Tables in the Terminal
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’.
Bringing the Unix Philosophy to the 21st Century
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.