NAME
std/data/toml - TOML encoding and decoding for ZuzuScript.
SYNOPSIS
from std/data/toml import TOML;
let codec := new TOML( pretty: true, canonical: true );
let text := codec.encode({ answer: 42, name: "Zuzu" });
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 TOML encode/decode coverage passes, but file-backed load/dump coverage is unsupported because browser filesystem capability is unavailable.
DESCRIPTION
This module provides a pure-Zuzu implementation of TOML parsing and serialization, with a user-facing API modelled on std/data/json.
EXPORTS
Classes
TOML({ utf8?: Bool, pretty?: Bool, canonical?: Bool })Constructs a TOML codec. Returns:
TOML.codec.encode(value)Parameters:
valueis aDictor compatible mapping. Returns:String. Encodesvalueas TOML text.codec.encode_binarystring(value)Parameters:
valueis aDictor compatible mapping. Returns:BinaryString. Encodesvalueas UTF-8 TOML bytes.codec.decode(String text)Parameters:
textis TOML text. Returns:Dict. Decodes TOML text into a dictionary.codec.decode_binarystring(BinaryString bytes)Parameters:
bytesis UTF-8 TOML bytes. Returns:Dict. Decodes TOML bytes into a dictionary.codec.load(Path path)Parameters:
pathis astd/ioPath. Returns:Dict. Reads TOML text frompathand decodes it.codec.dump(Path path, value)Parameters:
pathis astd/ioPathandvalueis aDictor compatible mapping. Returns:null. Encodesvalueand writes TOML text topath.
COPYRIGHT AND LICENCE
std/data/toml 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.