baml.toml.item_to_json

Converts a TOML item to a JSON value.

Reference version

Signature

function baml.toml.item_to_json(

Converts a TOML item to a JSON value.

Lossy: TOML datetimes become JSON strings — ZonedDateTime as RFC 3339, the Plain* types as zoneless ISO 8601. The conversion does not round-trip, because item_from_json reads those strings back as strings.

Throws

  • baml.json.SerializationError if a datetime cannot be formatted: a year outside the 4-digit range the ISO 8601 / RFC 3339 forms admit, or a ZonedDateTime naming an IANA zone the host does not know.

Source:<builtin>/baml/ns_toml/toml.bamlbytes 4790–5222