Formata.Codec.TOML (formata v0.1.0)

Copy Markdown View Source

TOML codec: decoding with Formata.Toml.decode/2 (forked from gsmlg_toml), encoding with Formata.Codec.TOML.Encoder.

Decoding

  • The root is always a map (table); keys stay strings.
  • inf, -inf, nan become :infinity, :negative_infinity, :nan.
  • Local date, local time, and local date-time become Date, Time, and NaiveDateTime.
  • Offset date-times become UTC DateTime values. Formata.Toml converts the instant to UTC, so the original offset (for example -08:00) is not preserved; the instant is.
  • Duplicate keys and table redefinitions are rejected by the decoder as :parse / :syntax errors.
  • Line/column are included when the decoder reports them.

Options: :filename (used in decoder messages).

Encoding

See Formata.Codec.TOML.Encoder for the accepted domain. nil has no TOML representation and is rejected; use Formata.Transform.drop_nils/1 or Formata.Transform.replace_nils/2 explicitly when that loss is acceptable.