Documentation
¶
Overview ¶
Package ndjson implements newline-delimited JSON as a codec.Codec. Each record is a JSON value followed by a single '\n' — the format is intentionally line-oriented so that partial reads remain parseable. The codec accepts slice values: Marshal emits one record per element, Unmarshal splits on '\n' and decodes each non-empty line into a new slice element.
Package ndjson — range 0.3.11.* (ADR 0005 service/codec/ndjson block).
Package ndjson — declares the sentinel *errs.Error values for NDJSON.
Index ¶
Constants ¶
const CodeNDJSONMarshalFailed errs.Code = 0x00_03_0B_01 // 0.3.11.1
CodeNDJSONMarshalFailed identifies a failure inside encoding/json.Marshal when encoding a single NDJSON record.
const CodeNDJSONUnmarshalFailed errs.Code = 0x00_03_0B_02 // 0.3.11.2
CodeNDJSONUnmarshalFailed identifies a failure inside encoding/json.Unmarshal when decoding a single NDJSON record.
const CodeNDJSONValueInvalid errs.Code = 0x00_03_0B_03 // 0.3.11.3
CodeNDJSONValueInvalid identifies a Marshal / Unmarshal call whose target is not a slice (NDJSON models a stream of records).
Variables ¶
var ( // MarshalFailed wraps a failure from encoding/json.Marshal on a single record. MarshalFailed = errs.Define(CodeNDJSONMarshalFailed, "MARSHAL_FAILED", "NDJSON encoding failed", "service/codec/ndjson: encoding/json.Marshal returned an error on a record") // UnmarshalFailed wraps a failure from encoding/json.Unmarshal on a single record. UnmarshalFailed = errs.Define(CodeNDJSONUnmarshalFailed, "UNMARSHAL_FAILED", "NDJSON decoding failed", "service/codec/ndjson: encoding/json.Unmarshal returned an error on a record") // ValueInvalid fires when the caller does not pass a slice target. ValueInvalid = errs.Define(CodeNDJSONValueInvalid, "VALUE_INVALID", "NDJSON codec requires a slice target", "service/codec/ndjson: Marshal/Unmarshal called with a non-slice argument") )
var ( //: register the singleton and expose it as a typed package var. Codec codec.Codec = codec.Register(&ndjsonCodec{}) )
Package-level state: the codec singleton plus the hoisted MIME / extension tables (hoisted).
Functions ¶
Types ¶
This section is empty.