TOML Parser for Erlang

CIHexTOML

tomerl is an Erlang library for parsing TOML 1.0.0-rc1 data, forked from toml by Stanisław Klekot.

The documentation at Hexdocs is updated on release, it can be generated locally via rebar3 edoc.

Usage Example

Assuming an input file called config.toml with the following content:

lipsum = "lorem ipsum dolor sit amet"

[apples]
count = 2

[berry.black]
has_some = true

the data can be read in Erlang like this:

{ok, Data} = tomerl:read_file("config.toml").

>>> Data = #{
    <<"lipsum">> => <<"lorem ipsum dolor sit amet">>,
    <<"apples">> => #{ <<"count">> => 2 },
    <<"berry">> => #{ <<"black">> => #{ <<"has_some">> => true }}
}.

To access the data, there is a simple get function that accepts lists of strings, binaries and atoms:

{ok, true} = tomerl:get(Data, [berry, black, has_some]),
{ok, 2} = tomerl:get(Data, ["apples", <<"count">>]),
{error, not_found} = tomerl:get(Data, [something, undefined]).