Skip to main content

JSON output

Commands that report information rather than records print one JSON document with --json (the same as --format-out json). Nothing else goes to stdout, so the output can be piped to jq or read by scripts and agents:

undatum count data.csv --json
undatum headers data.csv --json
undatum stats data.csv --json
{
"schema": "undatum.count/1",
"file": "data.csv",
"rows": 3
}
CommandSchema
countundatum.count/1
headersundatum.headers/1
sniffundatum.sniff/1
statsundatum.stats/1
schema (undatum's own format)undatum.schema/1
schema --validateundatum.schema-validation/1
diffundatum.diff/1
diff --schemaundatum.schema-diff/1
schema-driftundatum.schema-drift/1
validate --rulesundatum.validate/1
validate --fields ... --rule ...undatum.validate-rule/1
analyzeundatum.analyze/1
qualityundatum.quality/1
validate --list-rulesundatum.validate-rules/1
formats listundatum.formats/1
config showundatum.config/1

Record commands (head, frequency, uniq, select, ...) are different: with --json / -O json they print a JSON array of records, without an envelope. schema --format jsonschema|cerberus|avro|parquet prints that standard format as it is.

Versions​

The schema key names the layout and its major version. Adding a key is not a breaking change; removing or renaming a key, or changing its type, raises the version (undatum.stats/1 becomes undatum.stats/2), and the CHANGELOG says so. Check schema before reading a document:

import json, subprocess

result = json.loads(subprocess.run(
["undatum", "count", "data.csv", "--json"], capture_output=True, text=True, check=True
).stdout)
assert result["schema"] == "undatum.count/1"
print(result["rows"])

Errors​

With --json or --format-out json, errors are JSON too: one object on stderr, and the usual exit code (1 user error, 2 usage, configuration or missing dependency, 3 system, 4 internal, 130 interrupted).

undatum stats missing.csv --json
{
"error": {
"code": "file_not_found",
"message": "File not found: 'missing.csv'\nCheck that the file path is correct and the file exists.",
"exit_code": 1,
"details": {"file_path": "missing.csv"}
}
}
CodeExit codeMeaning
file_not_found1An input file does not exist
validation_error1An option value or field name is not valid
format_error1The file format is unknown or cannot be written
invalid_rules1A validation rule file is malformed
invalid_value1A value could not be processed
usage_error2Unknown option, missing argument
configuration_error2Bad configuration
dependency_missing2An optional extra is not installed
permission_denied3A file cannot be read or written
database_error3A database query or connection failed
internal_error4A bug — please report it
interrupted130Ctrl-C

Layouts​

Each layout is also published as a JSON Schema file (linked below).

undatum.count/1​

Number of records in a file. Printed by undatum count --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.count/1
filestringyesInput path
rowsintegeryesNumber of records

undatum.headers/1​

Field names of a file. Printed by undatum headers --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.headers/1
filestringyesInput path
fieldsarrayyesField names in file order (nested fields as dotted paths)

undatum.sniff/1​

Detected file properties. Printed by undatum sniff --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.sniff/1
filestringyesInput path
filetypestringyesDetected format id (csv, jsonl, parquet, ...)
compressionstring or nullCompression codec (gz, zst, ...), null if none
encodingstring or nullText encoding, null for binary formats
delimiterstring or nullField delimiter of delimited text, else null
has_headerboolean or nullWhether the first line is a header (CSV/TSV)
record_countintegeryesNumber of records
sample_sizeintegerRecords sampled for field types
fieldsobjectyesField name -> type and up to 3 examples

undatum.stats/1​

Field statistics. Printed by undatum stats --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.stats/1
countintegeryesRecords profiled
num_fieldsintegeryesNumber of fields
fieldtypesobjectyesField -> detected type
fieldsarrayyesPer-field statistics
dictkeysarrayFields with few distinct values
dictsobjectValue lists of the dictionary fields
debugobjectEngine diagnostics (engine, timings); not stable

undatum.schema/1​

Inferred table schema (undatum's own format). Printed by undatum schema --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema/1
idstringTable id (file name)
keystringHash of the field list
num_colsintegerNumber of fields
num_recordsintegerRecords read (-1 when not counted)
is_flatbooleanNo nested fields
descriptionstring or nullDescription (with --autodoc)
fieldsarrayyesFields: name, ftype, is_array, description, ...
filesarray or nullFiles with this schema (schema-bulk)
successbooleanInference succeeded
errorstring or nullError message when inference failed

undatum.schema-validation/1​

Rows checked against the inferred schema. Printed by undatum schema --validate --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema-validation/1
validbooleanyesNo invalid rows
statsobjectyesvalid, invalid, total, errors_by_field
invalid_samplearrayUp to 20 invalid rows with their errors

undatum.diff/1​

Records added, removed and changed between two files. Printed by undatum diff --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.diff/1
file1stringyesOld file
file2stringyesNew file
keyarray or nullKey fields (null: records compared whole)
summaryobjectyesfile1_count, file2_count, added_count, removed_count, changed_count
addedarrayRecords only in file2 (not with --summary-only)
removedarrayRecords only in file1 (not with --summary-only)
changedarrayChanged records with key, old and new (not with --summary-only)

undatum.schema-diff/1​

Schema changes between two files or declared schemas. Printed by undatum diff --schema --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema-diff/1
oldstringyesBaseline file or schema
newstringyesCompared file or schema
summaryobjectyesChanges per kind: added, removed, type, nullability
changesarrayyesChanges: kind, field, old and new type or nullability
renamesarrayyesLikely renames: old, new, name_similarity, value_overlap

undatum.schema-drift/1​

Schema changes of a set of files against a baseline. Printed by undatum schema-drift --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.schema-drift/1
baselinestringyesBaseline file or schema
summaryobjectyesfiles (compared) and drifted (with changes)
filesarrayyesPer file: file, summary, changes, renames

undatum.validate/1​

Rule-file validation report. Printed by undatum validate --rules --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.validate/1
statisticsobjectyestotal_records, total_violations, errors, warnings, info, passed
violations_by_fieldobjectField -> number of violations
violations_by_ruleobjectRule -> number of violations
violationsarrayyesViolations (at most --max-violations)

undatum.validate-rules/1​

Built-in validation rules. Printed by undatum validate --list-rules --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.validate-rules/1
rulesarrayyesRules: name, description, params, extra
keysobjectyesRule-file keys that are checks (required, unique, ...)

undatum.validate-rule/1​

Values checked against one built-in rule. Printed by undatum validate --rule --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.validate-rule/1
rulestringyesRule name, e.g. common.email
fieldstringyesChecked field
modestringinvalid, valid, all or stats
statisticsobjectyestotal, invalid, novalue, share (percent invalid)
recordsarrayChecked values with a FIELD_valid flag (omitted with --mode stats)

undatum.quality/1​

Data quality report with a pass/fail verdict. Printed by undatum quality --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.quality/1
filestringyesInput path
summaryobjectyesrows, fields, empty_values, violations per severity (null without --rules)
fieldsarrayyesPer field: name, type, values, nulls, null_rate, distinct, conformance, top_values
schema_checkobjectyesexpected, inferred types, changes and renames against --schema
violationsobjectyesby_severity, by_rule and a sample of rule violations
verdictobjectyespassed and the threshold checks (name, target, value, limit, passed)

undatum.analyze/1​

File analysis report. Printed by undatum analyze --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.analyze/1
filenamestringyesInput path
file_sizeintegerSize in bytes
file_typestringDetected format id
compressionstringCompression codec or raw
total_tablesintegerNumber of tables
total_recordsintegerNumber of records
tablesarrayyesPer-table structure: fields, types, descriptions
metadataobjectEncoding, delimiter and other file metadata
successbooleanAnalysis succeeded
errorstring or nullError message when analysis failed

undatum.formats/1​

Supported formats and their capabilities. Printed by undatum formats list --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.formats/1
formatsarrayyesFormats: id, readable, writable, ...

undatum.config/1​

Effective CLI configuration. Printed by undatum config show --json. JSON Schema

KeyTypeAlwaysDescription
schemastringyesundatum.config/1
filesobjectyesConfig files read: home, project
defaultsobjectyesMerged command defaults