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§
Structs§
- Components
- Iterator over the
Components of aPath; seePath::components. - Document
- The output of [
parse]: the element tree with path resolution embedded in each element. - ElemId
- Unique sequential index of a JSON
Elementwithin a document. - Element
- A JSON
Elementwith identity, source span, and value. - Error
- A parse error produced when the input is not well-formed JSON.
- Escape
Str - A
&strwith 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
&strwith surrounding quotes removed; escape sequences are not decoded. - Span
- Byte range of a JSON token within the source string.
Enums§
- Component
- A single
Pathcomponent: an object member or an array index. - Parse
Error - Parse
Error Kind - The specific reason a [
parse] call failed. - Pending
Str - Marks a
&stras having escapes or not. - Value
- A JSON value that borrows its content from the source JSON
&str. - Value
Kind
Functions§
- line_
col - Return the line and column indices of the end of the slice.
- parse_
object - Parse a raw JSON
&strinto aDocumentand require the root value to be a JSON object.