Predefined function reference

toml_decode

A reference entry for toml_decode

Predefined function · data

toml_decode (string data) ⇒ map

Parses a string in the TOML format to a map. The resulting map may contain additional maps inside it representing groups of values. For more information see https://en.wikipedia.org/wiki/TOML.

Notes

Unlike the INI parser, the TOML parser uses data types and converts values to data types. It supports strings, numbers, booleans and lists.

The TOML parser will parse comments, but will ignore them and they will not be included in the final output.

If there are no groups, the output will be put into the final map. Additionally, if properties are stated before a group is stated, they will be in the top level map.

# Basic settings
[General]
app_name = "MyApp"
version = "1.0.0"
supported_languages = ["English", "Spanish", "French"]

[UserSettings]
theme = "dark"
font_size = 12

[Network]
host = "192.168.1.1"
connection_max = 5000
enabled = true
port = 8080
hosts = [
  "alpha",
  "omega"
]

# Database settings
[Database]
host = "localhost"
port = 5432
[Database.credentials]
username = "admin"
password = "secret"