tpt-jsonl-stream 0.1.0

Streaming, zero-allocation JSON Lines (.jsonl) parser
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Example: write records to a JSON Lines buffer.
//!
//! Run with: `cargo run -p tpt-jsonl-stream --example write`

use std::io::Cursor;

use tpt_jsonl_stream::JsonlWriter;

fn main() {
    let mut buf = Cursor::new(Vec::new());
    {
        let mut writer = JsonlWriter::new(&mut buf);
        writer.write(&serde_json::json!({"a": 1})).unwrap();
        writer.write(&serde_json::json!({"b": 2})).unwrap();
        writer.flush().unwrap();
    }
    println!("{}", String::from_utf8(buf.into_inner()).unwrap());
}