std/toml
On this page
Index
- type
TomlErr- method
TomlErr.display
- method
- type
DecodeErr- method
DecodeErr.display
- method
- fn
decode - fn
to_json - fn
encode
Types
TomlErr
struct TomlErr {
line: Int
msg: Str
}Displays as toml: line 3: expected a value after =; an encode error
has line 0 and displays as toml: msg.
TomlErr.display
fn (e: TomlErr) display() -> StrDecodeErr
enum DecodeErr {
Syntax(err: TomlErr)
Value(err: json.DecodeErr)
}Why decode failed: the text is not TOML, or its values do not fit T.
DecodeErr.display
fn (e: DecodeErr) display() -> StrFunctions
decode
fn decode[T: Json](text: Str) -> T ! DecodeErrThe document decoded into T by the rules of json.decode; a document that is not valid TOML is TomlErr.
to_json
fn to_json(text: Str) -> Str ! TomlErrThe document as JSON text, its keys in document order.
encode
fn encode[T: Json](v: T) -> Str ! TomlErrv as a TOML document, laid out as pelletier/go-toml/v2’s Marshal: a
table’s plain keys first, then its tables ([a.b], a blank line
before each) and arrays of tables ([[a]]) in field order; strings as
literal strings (’…’) when they can be, else basic strings with
Go’s escapes; an array of values or mixed values inline. v goes
through json.to_value, so a None field is left out, Time and Duration
are their JSON strings, and a Float with no fraction is an integer
(decode reads each back). TomlErr (line 0) when v is not a record or
map, or an array holds a None.