Expand description
TOON v3.0 Decoder — converts TOON back into JSON.
The decoder parses indentation-based TOON structure back into a serde_json::Value
tree. It handles all TOON v3.0 constructs:
- Flat and nested objects (indentation-based)
- Inline primitive arrays (
key[N]: v1,v2) - Tabular arrays (
key[N]{f1,f2}:\n v1,v2) - Expanded lists (
key[N]:\n - item) - Quoted/unquoted keys and values with escape sequences
- Type inference: unquoted
true/false→ bool,null→ null, numbers → number
§Key design decisions
- Line-index tracking:
parse_key_value_into_mapreturns the next line index so callers can correctly skip past array bodies in nested structures. skip_array_bodyvsskip_nested_lines: Array bodies containing “- “ list items need special handling to avoid skipping sibling fields at the same indent.- Auto-detected indent:
parse_array_bodyfinds the first “- “ line’s indent rather than assumingbase_indent + 2, supporting flexible nesting depths.
Functions§
- decode
- Decode a TOON string back into JSON format.