Parsing a 186MB JSON array with readFileSync plus JSON.parse peaks at 612MB of resident memory; switching to stream-json's streamArray keeps it flat at 104MB. This guide walks through measured results for four reading strategies, explains why for await provides backpressure for free, how the data event loses it, and how to size highWaterMark and drain on the write side.
Intermediate~5 min readUpdated 2026-11-17
LLMs emit JSON token by token and APIs deliver big responses in chunks, but JSON.parse refuses to run until the whole document arrives. This guide separates three implementation styles — full repair, true incremental repair and partial parsing — and shows how an Allow mask keeps previews stable, backed by measured pipeline numbers and production-ready code.
Intermediate~5 min readUpdated 2026-11-16
The same NDJSON star-counting script takes 754 ms with the standard json library but only 146 ms with msgspec declarative decoding, and multi-core parallelism pushes it another order of magnitude. This article benchmarks stdlib, orjson, and msgspec step by step on a 61.4 MB, 300,000-line sample, and explains exactly where each speedup comes from and when it runs out.
Advanced~6 min readUpdated 2026-11-15
The model returns JSON that stops mid-value, and the parser only gives you a column number. Closing the brackets makes it parse again, but every missing field is now hidden inside the data. This article draws the line between what truncation repair can honestly recover and what must be retried, from stop_reason gating to schema field ordering.
Advanced~5 min readUpdated 2026-11-14