jsonCODEC
JSON
The JSON codec converts between line-delimited JSON byte payloads and columnar Arrow RecordBatches. Decoding uses Arrow's schema inference to map JSON objects to columns; encoding writes each row as one JSON object separated by newlines. It is the most common codec for attaching to inputs that emit JSON (Kafka, Redis, HTTP, etc.).
Configuration
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | yes | — | Fixed value "json" |
The decode-error policy is the engine-level on_error key on codec (fail/dlq/drop; skip is accepted as an alias of drop) — see Dead Letter Queues.
The configuration object can be omitted (i.e.
codec: { type: json }).
Examples
input:
type: kafka
brokers:
- localhost:9092
topics:
- events
consumer_group: arkflow
start_from_latest: false
codec:
type: json
output:
type: stdout
codec:
type: json
Notes
- Schema inference covers all records of the batch being decoded, not just the first: numeric columns widen to the union type (a column mixing integers and floats decodes as
Float64— integer values are not truncated, but IEEE-754 doubles only carry exact integers up to ±2^53, so keep identifiers beyond that range as strings; the same bound applies to unsigned values abovei64::MAXin a widened column), fields that first appear in later records still become columns (null-filled, nullable), and a column that is entirely integers staysInt64. - Downstream note: a mixed int/float column that older ArkFlow versions silently truncated to
Int64now decodes asFloat64with the correct values; SQL or output schemas that relied on the old (wrongly narrowed) type need to adapt. - In the default
failmode, multiple byte payloads are concatenated with\nand handed to the Arrow JSON reader in a single pass; one malformed message fails the entire batch. - In
skipmode each message is probed individually: parse-level bad messages are dropped with a warning (message index and error are logged), then the good messages are decoded together in one pass sharing the same full-batch schema inference asfailmode. A batch where every message fails still errors rather than returning an empty batch. - Encoded output is newline-delimited JSON (one object per line), convenient for downstream line-by-line parsing.
- This codec implements both
EncoderandDecoder, so it can be reused on both the input (decode) and output (encode) sides.