module

TOML

The TOML module allows parsing TOML documents through the usage of the tomlc99 C library

Parsing with TOML.parse

TOML.parse will return an Any, which is a convenient wrapper around all possible TOML types, making it easy to traverse a complex TOML structure but requires some casts from time to time, mostly via some method invocations.

require "ctoml-cr"

value = TOML.parse("x=[1, 2, 3]") # : TOML::Any

value[0]              # => 1
typeof(value[0])      # => TOML::Any
value[0].as_i         # => 1
typeof(value[0].as_i) # => Int32

value[0] + 1      # Error, because value[0] is TOML::Any
value[0].as_i + 1 # => 2

Documentation is an edited version of the JSON module from Crystal

Constants

PlaceholderLocation = Time::Location.new("None", zones: [PlaceholderZone])

When a timezone isn't explicitly specified this placeholder location is used

PlaceholderZone = Time::Location::Zone.new("None", 0, false)

Class methods

parse(data : String)

Parse a TOML document as a TOML::Any.

Source

Instance methods

build_test_json(toml_dict : Hash(String, TOML::Any))
Source

Nested types