Automate Moji with JSON
Use structured output and exit codes in scripts and pipelines.
Add --json whenever another program will parse the output:
moji "Futura" --format otf --jsonSearch output is an array of result objects. Each object includes:
name,filename,format, andweightsize_byteswhen knownsourceand the directurltrustedand the best-effortlicensehintarchive_formatandarchive_memberwhen the font is inside an archive- the calculated
score
Inspect a local font when a script needs to verify language coverage:
moji inspect Inter.woff2 --json |
jq '.scripts[] | select(.name == "Cyrillic")'Inspection output is one object with the file path, detected format,
optional family and subfamily, glyphs, unicode_version,
encoded_characters, and a scripts array. Each script entry contains its
name, encoded and assigned character counts, and numeric coverage
percentage. encoded_characters counts every mapped Unicode scalar, including
private-use characters. Scripts with zero encoded characters are omitted.
Select a field with jq
moji "Futura" --format otf --json |
jq -r '.[].url'Preview an automated download
moji get "Futura bold" --dry-run --json |
jq '.[0] | {filename, source, license}'Check exit status
if moji get "Futura bold" --dry-run --json > selection.json; then
jq '.[0]' selection.json
else
echo "Moji could not select a font" >&2
exit 1
fiMoji writes primary data to standard output and diagnostics to standard error.
Exit 0 means success, 2 means invalid command usage, and 1 means an
operational failure.