Skip to content
filmorPublic

About

Erlang TOML Parser

Resources

Stars

24 stars

Watchers

0 watching

Forks

Latest commit

 

History

149 Commits

Folders and files

Repository files navigation

TOML Parser for Erlang

CI Hex TOML License

tomerl is an Erlang library for parsing TOML 1.0.0 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]).

About

Erlang TOML Parser

Resources

Stars

24 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages