packages

json::read

On this page

Pull tokenizer and parser. The tokenizer reads a window of the input (all of it for a str, chunks for a reader) and yields Events, checking the grammar as it goes; parse builds a Value from them.

Structs

TokenizerSource

pub struct Tokenizer

A JSON reader yielding Events. new reads a string; from_reader reads any io::Read in 64 KiB chunks and keeps only the unread part of the current chunk, so memory stays flat for large inputs.

  • pub max_depth: usize§

    Source

    Nesting limit; deeper input is an error.

  • pub fn new(s: str) -> Tokenizer§

    Source

    Read s.

  • pub fn from_reader<R: Read>(r: R) -> Tokenizer§

    Source

    Read r to its end.

  • pub fn depth(self) -> usize§

    Source

    Nesting depth after the last event.

  • pub fn position(self) -> (u32, u32)§

    Source

    (line, col) where the last event's token starts.

  • pub fn next(ref self) throws (JsonError) -> Event§

    Source

    The next event. After End it keeps returning End.

Enums

EventSource

pub enum Event

One step of a document, in order. Every BeginObject / BeginArray is matched by its End*; inside an object each value follows its Key. End comes once, after the top-level value.

Functions

parse_withSource

pub fn parse_with(t: Tokenizer) throws (JsonError) -> Value

Read one document into a Value.

locateSource

pub fn locate(s: str, e: JsonError) -> JsonError

e (from decoding s) with the line:col of the value or key at e.path (a JSON Pointer).

Constants

MAX_DEPTHSource

pub const MAX_DEPTH: usize = 128

Nesting limit of parse / from_str / Tokenizer::new.