
JSON from command output, files and arguments, for the next command
jsonize makes JSON for the next command. jz turns what a command
printed, a CSV, YAML or text file, or the arguments of a script into
JSON and hands it on, to jq, curl or a CI step. When the input is not
what it should be, jz says so and prints nothing, so the next command
never reads a guess.

Try it in 30 seconds #
$ df -h | go run github.com/nao1215/jsonize/cmd/jz@latest
[{"filesystem":"/dev/nvme0n1p2","size":"1.8T","used":"1.6T","available":"145G","use_percent":92,"mounted_on":"/"}, ...]
A size rounded by -h stays the string df printed, and use_percent
is a number.
Three things to try next #
$ jz run --pretty free
$ jz --file users.csv --type id=int
$ jz new --string "message=$MESSAGE" --path /metadata/labels/app=api replicas:=3
Why jsonize? #
| You want | Use |
|---|---|
JSON from a command that has no --json option | COMMAND | jz or jz run COMMAND |
| a CSV, TSV, LTSV, JSON Lines or YAML file as JSON | jz --file FILE |
lines, or the names find -print0 prints, as a JSON array | COMMAND | jz --format lines (or nul) |
| a JSON body built in a shell script | jz new key=value key:=json |
| every record of a stream wrapped with the fields a consumer needs | jz --stream | jz new --each host=web sample:=@- |
| to select, sort or reshape JSON you already have | jq |
| a parser for a command jz does not know yet | a YAML definition in your own registry |
jz reads 280 commands through 758 definitions, from df, ps and ip
to kubectl get, docker ps, tasklist and diskutil list, on Linux,
macOS, Windows and FreeBSD. A definition is a YAML file with captured
output beside it; no Go code is needed to add one.
Data files and text #
A file is read as the format its extension names, and piped data as the
format --format names. Nothing is detected, a CSV column stays text
unless --type names its type, and text the format does not allow is
exit 3 with the line. --format lines and nul read plain text as a
list of strings.

JSON from arguments #
jz new builds a document from key=value (a string), key:=json (any
JSON value), key=@file (a file’s text) and key[]=value (an array).
--string passes text that must not be read as a file name, --path
places a value at a JSON Pointer, and --each makes one document per
line of standard input. Nothing is guessed from a value.

Install #
go install github.com/nao1215/jsonize/cmd/jz@latest
Homebrew, release archives, Linux packages and shell completion are on the install page.
Where to go #
- Cookbook: copyable recipes by task, each run by the test suite.
- Usage: every source of JSON, every option, streams and the exit codes.
- Parsers: the commands and variants jz reads, with their JSON Schemas.
- Compared with jc and jo: what each of the three does, and timings on the same input.
- Write a parser: add a definition for a command jz does not know.
- Definition format: the reference for the YAML.
- Design: why jz refuses rather than guesses.