A download described as JSON Lines needs a record-boundary contract, not just JSON-looking content. State whether every line contains a complete JSON value, which value shapes the application expects, and how the consumer identifies malformed or incomplete records.
A file can contain individually valid fragments while failing the advertised framing rule. Pretty-printed multi-line objects, extra progress text, or a truncated final record can break a line-oriented consumer. Review the actual downloadable bytes and the intended parser together.
The CSV publication review concerns a different consumer grammar. This guide concerns JSON Lines completeness and framing. Passing one format's checks says nothing about the other's contract.
Use the format’s stated rules accurately
The JSON Lines format description requires UTF-8 encoding, no byte order mark, and a valid JSON value on each line. Values need not be objects: null, for example, is valid JSON, while a blank line is not. It also explains that CRLF is supported because surrounding whitespace is ignored when parsing values.
The same source strongly recommends a line terminator after the final value but does not require it. Do not reject a valid final value solely for lacking that final terminator unless your application's stricter contract explicitly requires one.
Keep format validity separate from the application schema. A line containing null can satisfy the general format while failing an application that requires an object with a stable record identifier.
Create a record-level acceptance sheet
Record file identity, encoding, framing rule, application schema, expected number of records, final-record policy, and the treatment of errors. Identify whether the consumer stops on the first invalid record or preserves a report of rejected lines. That choice belongs in the application contract.
| Case | Format observation | Application decision |
|---|---|---|
| One compact object per line | Each line parses as a value | Check required fields separately |
| Blank line between objects | Not a valid JSON value | Report the specific line |
| Pretty-printed object across lines | Individual lines are incomplete values | Reject under this framing contract |
| Valid null line | Permitted general JSON value | Reject only if object schema requires it |
| Truncated last object | Incomplete JSON value | Mark incomplete; do not fabricate a record |
These are proposed acceptance fixtures, not reports of a real research export. Keep the expected format decision and schema decision in separate columns so a maintainer can explain each rejection.
Distinguish escaped content from physical boundaries
A string can contain an escaped newline representation without creating a physical record boundary. The actual file bytes determine whether the parser sees one complete line or two broken fragments. Inspect that distinction in a harmless synthetic fixture rather than relying on how an editor displays the string.
Use the real JSON parser for value validation. A regular expression that merely looks for braces will reject valid non-object values and can accept malformed content. Then apply the application schema and cross-record checks as separate stages.
Python's JSON documentation notes that JSON is not a framed protocol. Repeated ordinary JSON serialization does not automatically define a valid single JSON document or a correct line-delimited stream. The producer must deliberately implement the promised output format.
Test truncation and non-data residue
Add a file with one complete first record and an incomplete second record. The consumer should identify the incomplete record under its documented error policy. A parser accepting the first line does not establish that the entire asset is complete.
Keep an error ledger with physical line number, parse outcome, schema outcome, and a safe explanation. Avoid copying private record contents into public errors. A consumer can identify where a failure occurred without printing the full payload. When the producer retries or regenerates the file, preserve the old asset identity alongside the new result so a reviewer can tell whether the record was repaired or the entire input was replaced. Line numbers alone do not identify the same record across different exports.
Add a harmless diagnostic sentence before otherwise valid records. If the download promises only JSON Lines data, that sentence violates the contract. Keep progress logs and error explanations outside the data artifact rather than teaching consumers to ignore arbitrary unexpected text.
Also inspect the final exported file after any compression or packaging step. A valid producer output is not sufficient evidence if a later step publishes a different file. Record the identity of the reader-facing asset.
Define completeness beyond successful parsing
Parsing every line establishes grammar, not whether all intended records arrived. If the export has a known expected count or a separate completion manifest, compare it with the observed record count. Use verified producer semantics; do not invent a count when the source cannot provide one.
A fictional fixture containing three intended records should report three accepted application records. If one valid JSON null line violates the object schema, report two accepted and one rejected, rather than silently calling the file complete. The denominator is the three intended input records.
The acceptance brief should state whether partial results are usable. A consumer may preserve valid records for diagnosis while still refusing to call the whole download accepted.
Release a precise data contract
Publish the framing rule, expected value shape, required fields, error behavior, completeness evidence, and a small synthetic fixture set. Keep optional stricter application requirements explicitly labeled rather than attributing them to the general format.
The verification worksheet can preserve which facts come from the format description and which are your application choices. Recheck after changing serializers, exporters, packaging, or record schemas.
Approve when a reader can distinguish a malformed line, a valid but schema-incompatible value, a complete record without a final newline, and an incomplete asset. Those distinctions make the download implementable without treating every parsing problem as the same error.
