baml.toml.Table

A TOML [table](https://toml.io/en/latest#table): a collection of key/value pairs.

Reference version

Signature

class baml.toml.Table

A TOML table: a collection of key/value pairs.

A parsed document is itself a Table. Nested tables — [a.b], inline { ... }, and array-of-table entries — are Table values inside items.

Source:<builtin>/baml/ns_toml/toml.bamlbytes 1077–2971

Fields

Static methods

function

parse

(s: string) -> baml.toml.Table throws baml.toml.ParseError

Parses the text of a TOML file into a table.

Throws

  • baml.toml.ParseError if s is not valid TOML; if an integer does not fit BAML's 63-bit int (TOML integers are 64-bit, so the top and bottom of the TOML range are unrepresentable); or if a datetime names a calendar date that does not exist.

Implementations

baml.Concrete for T

Source:<builtin>/baml/core.bamlbytes 763–795

baml.FromJson for baml.toml.Table

Static methods

function

from_json

(j: baml.json.json) -> baml.toml.Table throws baml.json.DecodeError

Converts a JSON object to a TOML table.

Lossy: JSON null values are skipped, and datetime strings stay strings, since JSON has no datetime type to tell them apart by.

Skipping nulls rather than rejecting them is what makes this the forgiving entry point; item_from_json throws on a bare null.

Source:<builtin>/baml/ns_toml/toml.bamlbytes 1719–2491

baml.ToJson for baml.toml.Table

Instance methods

function

to_json

(self) -> baml.json.json throws baml.json.SerializationError

Renders the table as a JSON object.

Lossy in the same direction Item is rich: the baml.time.* arms render as strings, since JSON has no datetime type.

Source:<builtin>/baml/ns_toml/toml.bamlbytes 1126–1714