Class JsonlTokenReader

java.lang.Object
org.apache.juneau.marshall.json.JsonTokenReader
org.apache.juneau.marshall.jsonl.JsonlTokenReader
All Implemented Interfaces:
Closeable, AutoCloseable, RecordReader, TokenReader

public class JsonlTokenReader extends JsonTokenReader
Reference implementation of the public TokenReader surface for the JSONL / NDJSON format.

JSONL is a sequence of independent JSON values separated by newlines. There is no root container. This cursor models that as a flat top-level sequence at depth 0: each line's tokens are emitted in turn, and JsonTokenReader.next() returns TokenType.END_OF_STREAM only when the underlying input is exhausted.

The most ergonomic way to consume a JSONL stream is via JsonTokenReader.read(Class), which binds one line to a POJO per call:

try (TokenReader r = Jsonl.DEFAULT.readTokens(reader)) { while (r.canRead()) { MyRecord rec = r.read(MyRecord.class); process(rec); } }

Notes: