Skip to content
Latchkey

jc: Structure Command Output as JSON in CI

jc parses the output of common Unix commands into structured JSON, so a CI step can read a value reliably instead of scraping columns with awk.

Scraping ps or df with cut breaks the moment a format shifts. jc has purpose-built parsers for dozens of commands and file formats, turning them into JSON you can query with jq. This page focuses on the CI parsing workflow; the base reference is jc-command-output-json.

What it does

jc takes command output on stdin with a parser flag (like --ps or --dig), or runs the command for you with the "magic" syntax jc dig .... It emits JSON that mirrors the fields of that command, which downstream jq can filter deterministically.

Common usage

Terminal
ps aux | jc --ps | jq '.[] | select(.cpu_percent > 50) | .command'
# magic syntax: jc runs the command
jc dig example.com | jq '.[].answer[].data'
df -h | jc --df | jq '.[] | select(.use_percent | rtrimstr("%") | tonumber > 90)'

Options

FlagWhat it does
--ps / --df / --dig / --lsParse output of ps, df, dig, ls (and many more)
-pPretty-print the JSON output
-rRaw output: strings kept as strings, no type conversion
jc <command> ...Magic syntax: run the command and parse it
--help --parsersList every available parser

In CI

jc turns brittle log-scraping into a real query: df -h | jc --df | jq ... gates on disk usage without column math. The magic form jc dig ... is the cleanest in a pipeline. When jc has no parser for a tool, structure that tool with its own JSON flag or with gron, then apply the same jq step.

Common errors in CI

"jc: Parsing error: ..." means the input did not match the parser (wrong command, a locale that changed column headers, or an error line mixed in); pin LANG=C and pass only the command output. Using --dig on ps output produces empty or wrong fields, so match the parser to the command. Some parsers warn on unusual formats but still emit partial JSON, so validate the field you rely on.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →