TomlElixir (Toml Elixir v3.1.0)

Copy Markdown View Source

TomlElixir

TOML parser for elixir.

Installation

The package can be installed by adding toml_elixir to your list of dependencies in mix.exs:

def deps do
  [{:toml_elixir, "~> 3.0.0"}]
end

Usage

TomlElixir is used by calling decode functions

Summary

Functions

Decode toml string to map.

Same as decode/2, but raises error on failure.

Encode map to toml string.

Same as encode/2, but raises error on failure.

Types

options()

@type options() :: map() | keyword()

Functions

decode(str, opts \\ [])

@spec decode(binary(), options()) :: {:ok, map()} | {:error, Exception.t()}

Decode toml string to map.

Options

  • :spec - The TOML specification version to follow. Can be :"1.1.0" (default) or :"1.0.0".

Example

TomlElixir.decode("toml = true", spec: :"1.1.0")

decode!(str, opts \\ [])

@spec decode!(binary(), options()) :: map()

Same as decode/2, but raises error on failure.

Example

TomlElixir.decode!("toml = true")

encode(map, opts \\ [])

@spec encode(map(), options()) :: {:ok, binary()} | {:error, any()}

Encode map to toml string.

Example

TomlElixir.encode(%{a: 1})

encode!(map, opts \\ [])

@spec encode!(map(), options()) :: binary()

Same as encode/2, but raises error on failure.

Example

TomlElixir.encode!(%{a: 1})