std/toml

TOML 1.0 and every later 1.x as a format, written in TorbScript: Toml reads and writes any Encode/Decode type, and TomlValue is the tree of a document, for one whose shape is not known ahead of time.

const toml = Toml()
const config = toml.decode<Config>(text)?
print(toml.encode(config)?)

A document is a table. A value is written as TOML only when it is a record or a map, a field that holds None is left out, and the same field absent from a document reads as None or as the field's default. TOML has no null, so None inside an array is an error of Toml.encode.

The reader takes every released 1.x. What 1.1 adds - inline tables over several lines, a time without seconds, the escapes \e and \xHH - is read in every document, and TomlVersion only chooses what the writer may use. Dates and times keep their nanoseconds and their offset: TomlOffsetDateTime, TomlLocalDateTime, TomlDate and TomlTime are the types to have a field of, and a String field reads the text of a date or a time.

The reader passes the public toml-test suite for TOML 1.0 and 1.1.

Modules

Everything