Expand description
The text syntax: JSON, plus // and /* */ comments, trailing commas
and unquoted keys (the part of JSON5 editors already understand).
parse keeps where every value is (Spans), so a schema error at
entries[2].pages[0].item can point at its line. Typed values stay
strings here — the schema decides what a string means.
Structs§
- Doc
- A parsed document: the value and where each of its parts is.
- LineCol
- A 1-based line and column (in characters).
- Span
- A byte range of the source.
- Spans
- Where each value of a parsed document is: the value’s span, its key’s (map entries), and its children’s, in the same order as the value’s.
- Syntax
Error - A syntax error.
- Writer
- Writes the text form piece by piece, without a
Valuein between. A list or map is given its length, then that many values (a map’s each after itskey); it closes by itself after the last, so there are no end calls. The pretty form puts one entry per line.
Constants§
- MAX_
DEPTH - Deeper than this is an error, not a stack overflow.
Functions§
- parse
- Parses text.
- parse_
ref - Parses text straight to a borrowed value, the way a schema reads it: no
positions, and nothing is allocated on the heap per value — strings
without escapes point into
text, lists and maps are inarena. - parse_
value - Parses text, without the positions (faster).
- to_
string valueas compact text (typed values in their string forms).- to_
string_ pretty valueas text indented by two spaces, one entry per line.- with_
comments text’s value, its comments in it (see the module docs).- write_
string sas a JSON string literal.