tpt-jsonl-stream
Streaming, zero-allocation JSON Lines (.jsonl) parser for Rust.
AI and data-engineering pipelines use massive JSONL files. Standard parsers load the whole file into RAM. This crate streams line-by-line from any BufRead.
Features
- Streaming — reads one line at a time; constant memory regardless of file size
- Error context — every error carries the exact 1-based line number
- Optional SIMD — enable the
simdfeature for 3× JSON parse throughput on AVX2 CPUs - Simple iterator API —
for value in parse_jsonl(reader) { ... }
Usage
use parse_jsonl;
use BufReader;
use File;
let f = open.unwrap;
for result in parse_jsonl
SIMD acceleration
[]
= { = "0.1", = ["simd"] }
Requires an AVX2-capable CPU. Falls back to standard parsing on unsupported hardware at compile time.
Error handling
use parse_jsonl;
use BufReader;
let data = b"{\"a\":1}\nNOT_JSON\n{\"c\":3}\n";
for result in parse_jsonl
Writing
The crate is also a JSON Lines writer. [JsonlWriter] emits one
newline-terminated JSON value per call; [write_jsonl] writes a whole
sequence in one go.
use JsonlWriter;
use Cursor;
let mut buf = new;
assert_eq!;
License
Licensed under either of Apache License 2.0 or MIT at your option.