Parsers

On this page

jz list prints the table below from the binary you have. jz list df shows the variants of one command and jz list df gnu everything about one definition, including where it came from and how it detects its input. Each variant below links to the JSON Schema of what it produces; what each definition produces says what those promise.

A handful of entries describe a shape rather than a command: table (whitespace, aligned, box), csv (comma, tab), kv (colon, equals) and ini (default). They are never chosen on their own — two words above two words says nothing about what produced them — and are reached by naming both halves:

$ sqlite3 -box app.db 'select * from users' | jz --parser table --variant box
$ jz --parser ini --file /etc/NetworkManager/NetworkManager.conf

They convert nothing: a shape says nothing about what its columns mean, so every value is the text it was cut from. Use --define where you want the same reading with settings of your own.

Supported commands #

CommandVariants
7zlist, list-technical, list-technical-bare
actionlintdefault
amixercontents, simple-controls
aplaydevices
aptlist, show
apt-cachedepends, madison, policy, rdepends, search, show, stats
apt-configdump
artable-verbose
arpalternate, darwin, freebsd, net-tools, windows
avahi-browseparsable
batlist-languages
blkidexport, linux
bluetoothctlshow
brewoutdated
bridgefdb, link
busctllist, tree, tree-services
capshprint
cargocommand-list, install-list, search, tree, verbose-version
chagelinux
chcpwindows
chrtpolicy
cksumposix
cloud-initstatus-long
cmpposix
cpupowerfrequency-info
csrutilstatus
csvcomma, comma-no-header, tab, tab-no-header
curlheaders, version
dateposix, rfc-email
debconf-showlinux
dfbsd, bsd-human, busybox-human, freebsd, freebsd-blocks, freebsd-blocks-type, freebsd-human, freebsd-inodes, freebsd-type, freebsd-type-human, gnu, gnu-blocks, gnu-blocks-type, gnu-human, gnu-inodes, gnu-inodes-human, gnu-type, gnu-type-human, portable, portable-blocks, portable-type
diffstatdefault
diganswers, axfr, bind
diskutillist
dockerbuildx-ls, compose-ls, compose-ps, context-ls, images-disk-usage, images-repo-tag, network-ls, ps, ps-size, stats, system-df, system-df-verbose, version, volume-ls
dpkglist, selections, status
dpkg-debinfo
dpkg-divertlist
dpkg-querylist
driverquerytable, verbose
dugnu-human, posix
dumpe2fssuperblock
e2freefraglinux
efibootmgrlinux
eglinfobrief
envnull-separated, posix
etccrontab, fstab, group, hosts, nsswitch, os-release, passwd, protocols, resolv-conf, services
ethtooldriver-info, features, pause, ring, settings, statistics
exifdefault
exiftooldefault, groups
ezafull-iso, long, long-group, long-iso, long-links
factordefault
fc-listposix
fc-matchdefault
fdesetupstatus
fdisklinux
filemime, posix
filefragverbose
fincorebytes, linux
findmntdf, linux, source-first
freegnu, gnu-human, gnu-wide, gnu-wide-human
gccprint-search-dirs
gdisklist
getcappaths
getconfglibc
getentahosts
getfaclposix
getmacverbose
ghauth-status, issue-list, pr-list, release-list, repo-list, run-list, workflow-list
giomime
gitbranch, branch-verbose, cherry, clean-dry-run, config-list, config-list-origin, count-objects, count-objects-human, diff-name-status, diff-numstat, diff-shortstat, diff-stat, diff-summary, for-each-ref, log, log-name-only, log-name-status, log-numstat, log-oneline, log-stat, ls-files-eol, ls-files-stage, ls-remote, ls-tree, ls-tree-long, notes-list, reflog, remote-verbose, shortlog-summary, show-ref, stash-list, status-porcelain, status-porcelain-v2, status-short-branch, submodule-status, worktree-list, worktree-porcelain
glxinfobrief
gobench, dist-list, env, list-modules, mod-graph, test, tool-cover-func, version, version-modules, vet
gocyclodefault
golangci-linttext
gpgcolons, list-keys, version
gpgconflist-components, list-dirs
gsettingslist-recursively
gziplist, list-verbose
hciconfiglinux
hexdumpcanonical
hostbind
hostnameall-addresses
hostnamectllinux
hyperfinebasic
iconvlist
idposix
identifydefault
ifconfigbsd, busybox, net-tools, net-tools-short
inidefault
ioniceclass
iostatcpu, cpu-timestamped, device, device-timestamped, extended, extended-device, extended-timestamped, freebsd-extended, human, human-sizes, human-sizes-timestamped, human-timestamped, linux, linux-timestamped
ipaddress, brief-address, brief-link, link, multicast-address, neighbour, oneline-address, oneline-link, route, route-get, rule, stats-link, stats-link-detail
ipconfigall, windows
ipcslimits, linux, message-queues, semaphores, shared-memory
isoinfovolume-descriptor
iwdev, link, reg-get
journalctlboots, short, short-iso, short-monotonic, short-precise
justlist
kldstatfreebsd, freebsd-human
kubectlapi-resources, contexts, deployments, namespaces, nodes, pods, services, version
kvcolon, equals
lastbusybox, freebsd, freebsd-year
launchctllist
ldconfigcache
lddfiles, posix
lipoinfo
localekeywords, locales, posix
localectllinux
loginctlseats, sessions, show, users
losetupassociations, linux, raw
lpstatdevices, printers, status
lsfull-time, long, long-context, long-inode, long-iso, long-no-group, long-no-owner, long-no-owner-group, long-recursive, names, names-zero
lsattrlinux
lsb_releaselinux
lsblkbytes, filesystems, filesystems-raw, linux, no-headings, pairs, permissions, permissions-raw, raw, topology, topology-raw
lsclockslinux
lscpucaches, extended, linux, parsable
lsfdlinux, raw
lshwbusinfo, short
lsipclinux, queues, raw, semaphores, shmems
lsirqlinux
lslockslinux, raw
lsloginslinux, raw
lsmemlinux
lsmodbusybox, linux
lsnslinux
lsoflinux, tasks
lspcikernel, linux, machine, numeric, numeric-names, verbose, verbose-machine
lsusblinux, tree, verbose
lz4list
mcls
md5bsd
md5sumcheck, posix
memory_pressuredarwin
misels, outdated
modinfolinux
mokutilsbat
mountbsd, linux
mpstatinterrupts, linux
mtrreport
nameilong
netlocalgroup, share, start, user
netstatall-sockets, darwin-interface, freebsd-interface, freebsd-interface-bytes, freebsd-routing, interface, internet, routing, unix, windows, windows-ethernet, windows-pid
networkctllist
networksetuphardware-ports
nmdynamic
nmcliconnection, device, device-show, device-terse, general, radio, wifi
npmls, ls-all, outdated
nslookupquery
nstatcounters
numactlhardware, show
objdumpsection-headers
odhex-bytes
oomctldump
opensslciphers, ciphers-codes, version-all, x509-fields, x509-text
otoollibraries
pactlinfo, short-cards, short-clients, short-devices, sinks
partedmachine
partxbytes, show
passwdstatus
pdffontspoppler
pdfimageslist
pdfinfopoppler
pgreplist-name
pidstatio, kernel, linux, memory, priority, stack, switches, threads, user
pingbsd, linux
pinkylong, short, short-iso
pipcolumns, columns-outdated, freeze
pkg-configlist
pmapextended, linux
pmsetsettings
powerprofilesctllist
prlimitlinux
prostatus-unattached
procbuddyinfo, cgroups, consoles, cpuinfo-x86, crypto, devices, diskstats, filesystems, interrupts, loadavg, meminfo, modules, mountinfo, net-arp, net-dev, net-if-inet6, net-route, net-sockstat, net-unix, partitions, pressure, schedstat, self-io, self-limits, self-maps, self-status, softirqs, stat, uptime, vmstat
procsdefault
psbsd, bsd-short, busybox, freebsd, freebsd-long, full-format, jobs, long, long-y, posix, threads, unix
pw-clilist-objects
pwdxdefault
rclonelsd, lsl, version
readelfdynamic, header, sections-wide, symbols-wide
redis-cliclient-list, info
resolvectlper-link, query, status
rfkilllinux, list
routelinux, linux-extended, linux-inet6, windows
rpminfo
rsyncitemize, stats
rustcverbose-version
rustupcheck, component-list, target-list, toolchains, toolchains-verbose
sarcpu, cpu-all, cpu-frequency, disk, filesystem, hugepages, icmp, icmp-errors, icmp6, icmp6-errors, interrupts, io, ip, ip-errors, ip6, ip6-errors, kernel-tables, memory, memory-all, network-device, network-errors, nfs-client, nfs-server, paging, queue, sockets, sockets6, softnet, swap, swapping, task, tcp, tcp-errors, udp, udp6
scquery, queryex
sccdefault
schtaskslist, table
screenlist
scutildns
sensorslinux, no-adapter, raw
servicestatus-all
setxkbmapquery
sfdiskdump
sgdiskprint
sha1sumposix
sha224sumposix
sha256sumposix
sha384sumposix
sha512sumposix
shellcheckgcc
sizegnu, sysv
smartctlscan
snapaliases, changes, connections, list, refresh-list, services, version
sockstatfreebsd, freebsd-state
spctlstatus
ssconnected, linux, single-protocol, summary
sshconfig-dump
ssh-addpublic-keys
ssh-keygenfingerprint
ssh-keyscanknown-hosts
statbsd, bsd-verbose, gnu, gnu-filesystem, gnu-terse
staticcheckdefault
sttylinux
sumbsd
sw_versdarwin
swapinfofreebsd, freebsd-human
swaponlegacy, linux
sysctlfreebsd, linux
syslogrfc3164, rfc5424
system_profilerdata-type
systemctlautomounts, dependencies, jobs, machines, paths, show, show-properties, sockets, status, timers, unit-files, units, units-jobs, units-jobs-plain
systemd-analyzeblame, calendar, critical-chain, security, time, timespan, timestamp
systemd-cglstree
systemd-cgtopbatch
systemd-deltano-diff
systemd-id128show
systemd-inhibitlist
systemd-pathpaths
systeminfowindows
tablealigned, box, whitespace
tarbusybox, gnu
tasklist
tasklistcsv, list, modules, services, table, verbose
tasksetaffinity-list, affinity-mask
tcqdisc, qdisc-stats
tesseracttsv
timedatectllinux, show, timesync, timezones
tokeidefault
topbusybox, darwin, linux
tracepathlinux
treelisting
trustlist
tune2fssuperblock
udevadminfo
udisksctlstatus
ulimitbash, dash
unamedarwin, freebsd, linux
unzipbusybox, info-zip
update-alternativesquery, selections
upowerdevice, dump, enumerate
uptimebsd, freebsd, linux, pretty, since
usb-deviceslinux
uuidparselinux, raw
uvpip-show, python-list, tool-list, tree
verwindows
vm_statdarwin
vmstatfreebsd-interrupts, linux, linux-active, linux-disk, linux-disk-summary, linux-partition, linux-stats
wbsd, freebsd, linux, linux-short
wcposix
whoiso, posix
whoamigroups, privileges
wipefserase, linux
xinputlist
xpropdefault
xrandrlinux, listmonitors
xwininfostats
xxddefault
xzlist, list-robot
zdumpcurrent, verbose
zfslist
zipinfodefault
zpoollist
zstdlist, list-verbose

A variant is one output format of a command. GNU df, df -h, macOS df and BusyBox df -h are four formats, so they are four definitions. When several implementations print the same format, one definition covers them and says so in its metadata.

Some commands print what another command prints. Nothing in the text says which of them wrote it, so they share a definition rather than having one each, and the command they are listed under is the one the definition is named for. These are read as well:

7za (as 7z), arecord (as aplay), b2sum (as md5, md5sum, sha256sum, sha384sum, sha512sum), batcat (as bat), cksum (as md5, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, sum), dpkg-deb (as tar), g++ (as gcc), gb2sum (as md5, md5sum, sha256sum, sha384sum, sha512sum), gcksum (as cksum, md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum), gdate (as date), gdf (as df), gdu (as du), genv (as env), getent (as etc), gfactor (as factor), gid (as id), gls (as ls), gmd5sum (as md5, md5sum), gpg2 (as gpg), gpinky (as pinky), gsha1sum (as md5, sha1sum), gsha224sum (as md5, sha224sum), gsha256sum (as md5, sha256sum), gsha384sum (as md5, sha384sum), gsha512sum (as md5, sha512sum), gstat (as stat), gstty (as stty), gsum (as sum), gtar (as tar), guname (as uname), gwc (as wc), gwho (as who), hd (as hexdump), mcli (as mc), md5sum (as md5), nerdctl (as docker), netstat (as route), ping6 (as ping), pip3 (as pip), podman (as docker), printenv (as env), python (as pip), python3 (as pip), rmd160 (as md5), route (as netstat), sha1 (as md5), sha1sum (as md5, md5sum), sha224 (as md5), sha224sum (as md5, md5sum), sha256 (as md5), sha256sum (as md5, md5sum), sha384 (as md5), sha384sum (as md5, md5sum), sha512 (as md5), sha512sum (as md5, md5sum), sha512t224 (as md5), sha512t256 (as md5), shasum (as md5, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum), skein1024 (as md5), skein256 (as md5), skein512 (as md5), ssh-add (as ssh-keygen), systemd-resolve (as resolvectl), ua (as pro), uv (as pip), vdir (as ls)

jz run, --parser and jz list all take the other name.

What each definition produces #

Every definition has a JSON Schema of its output, derived from the definition rather than written beside it: the keys are its columns, groups and parts, the types are its field conversions, a key is required when every object carries it, and a value may be null where the engine can leave it empty (an aligned cell with nothing under it, a group that did not take part, a value null_if names). A group that can only match a few literals is an enum. Where the keys come from the input, as in a table that names its columns from its header, the schema says what the values look like instead of naming the keys.

$ jz list --schema df gnu
$ jz list --schema df gnu | jq '.items.required'

The schemas are published under https://nao1215.github.io/jsonize/schemas/COMMAND/VARIANT.json, the $id of each, and every fixture in the registry is checked against its own on every change, by jz and by an independent validator.

x-jsonize.version is the version of that output contract. It is not format, which versions how a definition is written; the two change for unrelated reasons. A change a program reading the output could be broken by — a key removed, a type changed or made nullable, an object become an array, a key that is no longer always there or that now always is, a value added to or taken from an enum — is refused unless the version goes up with it. Adding a key that may appear is the one change that keeps the version. The JSON jz prints carries no version: the definition it was read with, which --explain names, identifies the contract.

How a definition is chosen #

Every definition carries a signature: the shape its output has.

detect:
  os: [linux]
  args: {any: ["-h"], none: ["-i"]}
  signature:
    all: ['^Filesystem\s+Size\s+Used\s+Avail\s+Use%\s+Mounted on\s*$']

The signature is a necessary condition. The operating system and the arguments are known only when jz ran the command itself; they can then remove candidates, never promote one. Exactly one survivor is a success. Zero and more than one are errors that say what to pass.

Some formats are not evidence of anything. A number, a tab and a path describes du output and git diff --numstat alike, and three numbers in a row describe almost any table. Such a definition sets auto_detect: false: it stays out of automatic detection and is used when you name it, where its signature is still checked.

What jz will not invent #

A rounded, human-readable number reaches JSON exactly as printed. The base behind a suffix is not in the output (df -h steps by 1024, df -H by 1000) and the value is rounded either way, so a byte count would be two guesses stacked. Ask the command for exact numbers when you need them: df, free, lsblk -b.

Where the exact and the rounded form of a command are separate definitions, the exact one gives numbers: df does, df -h does not. That split needs the two forms to be told apart, and telling them apart means reading the values, which jz only sees for the first 200 lines. A listing has no length limit, so ls -l and ls -lh are one definition and its size is a string in both. The rule is the same one; what changes is whether jz can know which form it has.

The same reasoning applies to env: a value containing a newline cannot be told from two variables in the line-based output, so env -0 | jz exists for the cases where that matters.

NAME=value is also what a .env file, a properties file and a shell fragment look like, so the line-based form is one of the definitions jz will not claim on sight. env | jz --parser env and jz run env read it; env -0 is distinctive and needs no name.