NAME
std/data/toon - Pure-Zuzu TOON codec.
SYNOPSIS
from std/data/toon import TOON;
let codec := new TOON( indent: 2 );
let text := codec.encode({ answer: 42 });
let data := codec.decode(text);
IMPLEMENTATION SUPPORT
This module is supported by zuzu.pl, zuzu-rust, and zuzu-js on Node and Electron. It is partially supported by zuzu-js in the browser: in-memory TOON parsing and serialization coverage passes, but fixture and load/dump coverage is unsupported because browser filesystem capability is unavailable.
DESCRIPTION
A pure ZuzuScript TOON codec with encode, decode, load, and dump.
The implementation supports:
- object and array roots
- inline primitive arrays and tabular/list arrays
- delimiter declarations (comma, tab, pipe)
- strict-mode validation for required colons
Object decoding defaults to PairLists so key order is kept.
EXPORTS
Classes
TOON({ indent?: Number, strict?: Boolean, delimiter?: String, pairlists?: Boolean, expandPaths?, keyFolding?, flattenDepth? })Constructs a TOON codec. Returns:
TOON.codec.decode(String text)Parameters:
textis TOON text. Returns: value. Decodes TOON text into ZuzuScript data.codec.decode_binarystring(BinaryString bytes)Parameters:
bytesis UTF-8 TOON bytes. Returns: value. Decodes TOON bytes into ZuzuScript data.codec.encode(value)Parameters:
valueis a TOON-encodable value. Returns:String. Encodesvalueas TOON text.codec.encode_binarystring(value)Parameters:
valueis a TOON-encodable value. Returns:BinaryString. Encodesvalueas UTF-8 TOON bytes.codec.load(Path path)Parameters:
pathis astd/ioPath. Returns: value. Reads TOON text frompathand decodes it.codec.dump(Path path, value)Parameters:
pathis astd/ioPathandvalueis a TOON-encodable value. Returns:null. Encodesvalueand writes TOON text topath.
OPTIONS
indent(default 2)strict(default true)delimiter(default comma)pairlists(default true)Decode objects as PairLists (preserves key order). Set false to decode as Dict.
expandPaths,keyFolding,flattenDepthAccepted for API compatibility.
COPYRIGHT AND LICENCE
std/data/toon is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.