Interface TokenReader

All Superinterfaces:
AutoCloseable, Closeable, RecordReader
All Known Implementing Classes:
CborTokenReader, Json5lTokenReader, Json5TokenReader, JsonlTokenReader, JsonTokenReader, MsgPackTokenReader

public interface TokenReader extends RecordReader
Public low-level pull-parser cursor over a Juneau-formatted document.

A StAX-like enum cursor that emits a stream of TokenType events without materializing the whole object graph. This is a format-neutral surface; the same cursor methods work across every Juneau format that implements TokenReadable (the structural-token role).

Usage:

// Tokenize a JSON document without materializing it. try (TokenReader r = Json.DEFAULT.readTokens("{\"a\":1,\"b\":[true,null]}")) { while (r.next() != TokenType.END_OF_STREAM) { switch (r.getCurrentToken()) { case FIELD_NAME -> handleKey(r.getFieldName()); case VALUE_STRING -> handleString(r.getString()); case VALUE_NUMBER -> handleNumber(r.getNumber()); default -> { // structural } } } }

Contract:
  • The cursor is purely structural. It bypasses object swaps and @Schema annotations — that is the role of the POJO databind path on Parser and its bridges.
  • For numeric values both the original lexeme and a parsed Number are available (see getNumberLexeme() and getNumber()); precision-sensitive consumers should prefer the lexeme.
  • Concrete implementations are not required to be thread-safe.
See Also: