GizStack
View .mdOpen in ChatGPTOpen in Claude

gizlang/toml

TOML 1.0 text to the JSON value model (gizlang/json Json) and back.

  • parse reads a document into an object. Tables, arrays of tables, dotted keys and inline tables nest as objects and arrays; integers and floats are numbers (f64: an integer past 2^53 loses its low digits); a date, a time or a date-time is a string of its text. A key defined twice, a table defined twice or a table extended after it was closed (an inline table, an array) is an error with its line. - stringify writes an object: its plain keys first, then each table under a header and each array of objects as an array of tables, so parse gives the value back. TOML has no null: a null field is left out, and a null in an array is an error.
gizlang
import * as Toml from "gizlang/toml";

Types

TomlError

gizlang
type TomlError = { line: i64; message: string; }

Where a text stops being TOML (its line, from 1), or why a value has no TOML form (line 0).

  • line: i64
  • message: string

Functions

parse

gizlang
function parse(text: string): Json throws TomlError

The document TEXT as an object.

Effects: fail, alloc.

stringify

gizlang
function stringify(value: Json): string throws TomlError

VALUE, an object, as a TOML document.

Effects: fail, alloc.