Skip to main content

Module json

Module json 

Source
Expand description

JSON parsing and typed decoding for the OCPI CDR pricing/generating and CDR/Tariff linting pipeline.

§Parsing vs decoding

Parsing and decoding are intentionally separated so the linter can emit actionable warnings rather than hard parse errors.

Parsing ([parser], [parse]) converts a raw JSON &str into an Element tree. The parser is deliberately lenient about string content: it only verifies structural correctness (balanced delimiters, valid top-level values) and leaves escape sequences and control characters untouched inside RawStr.

Decoding (decode) interprets the raw JSON String as a &str. Calling RawStr::decode_escapes validates escape sequences and rejects control characters, returning decode::Warning values instead of hard errors. This lets the linter pinpoint the exact field, report what is wrong, and suggest a corrected encoding. The price and generate mods can choose to hard fail on specific Warnings.

Modules§

decode
String decoding for JSON values parsed by super.
write
Tools for writing JSON.

Structs§

Components
Iterator over the Components of a Path; see Path::components.
Document
The output of [parse]: the element tree with path resolution embedded in each element.
ElemId
Unique sequential index of a JSON Element within a document.
Element
A JSON Element with identity, source span, and value.
Error
A parse error produced when the input is not well-formed JSON.
EscapeStr
A &str with escape chars.
Field
An object field; upholds the invariant that the inner Element’s path ends with a key.
Location
A file location expressed as line and column.
Path
PathSet
Set of path with a common issue.
RawStr
A &str with surrounding quotes removed; escape sequences are not decoded.
Span
Byte range of a JSON token within the source string.

Enums§

Component
A single Path component: an object member or an array index.
ParseError
ParseErrorKind
The specific reason a [parse] call failed.
PendingStr
Marks a &str as having escapes or not.
Value
A JSON value that borrows its content from the source JSON &str.
ValueKind

Functions§

line_col
Return the line and column indices of the end of the slice.
parse_object
Parse a raw JSON &str into a Document and require the root value to be a JSON object.

Type Aliases§

RawMap
RawRefMap