parseSequence
Parses a JSON text sequence (RFC 7464, application/json-seq): records that each start with
the ASCII record separator (RS, U+001E) and hold one JSON text, as written by jq --seq.
Accepts:
- one strict JSON value per record (each record is read like parseStrict)
- JSON values spread over several lines inside a record — unlike parseLines
- several RS in a row (empty records are ignored, as the RFC’s grammar allows)
- an empty text, which holds zero records
Rejects (as invalid records):
- anything before the first RS
- a record that isn’t strict JSON, or holds only whitespace
- a top-level number,
true,falseornullnot followed by whitespace — RFC 7464 §2.4 requires dropping it, since it may have been truncated
On invalid input: throws a SyntaxError naming the 1-based record number, with the
original parse error (if any) as its cause — unless invalidRecords: 'skip' says to drop it.
Available since v3.1.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | string | The JSON text sequence |
options | ParseSequenceOptions | How to handle invalid records — see ParseSequenceOptions |
Returns
Section titled “Returns”T[] — The parsed values, in record order, typed as T[]
Examples
Section titled “Examples”Read a JSON text sequence
Section titled “Read a JSON text sequence”Each record starts with the record separator U+001E, as jq —seq writes it.
Recover from a truncated log
Section titled “Recover from a truncated log”RFC 7464 recommends skipping invalid records; ask for it with invalidRecords: “skip”.
Related Types
Section titled “Related Types”ParseSequenceOptions
Section titled “ParseSequenceOptions”Options for parseSequence and safeParseSequence.
