TOML
classin packageklyn.io.toml
public class TOML:
TOML

Loads, parses, serializes and saves TOML 1.1 documents.

Parsed TOML tables become SortedMap<String, Object> values and arrays become Klyn lists. Serialization accepts any Map<String, Object>, including SortedMap and HashMap. Strings, signed 64-bit integers, doubles and booleans retain their natural Klyn type. Offset date-times become DateTime; local temporal values become TOMLLocalDateTime, TOMLLocalDate or TOMLLocalTime. Comments and original lexical formatting are intentionally not retained by the data model.

Example
import klyn.io.toml

config = TOML.parse("""title = "Klyn"
[server]
port = 8080
""")
server = config["server"] as SortedMap<String, Object>
assert server["port"] == 8080l
Methods
Modifier and Type Member Description
public static load Loads a TOML document from a UTF-8 file.
public static load Loads a TOML document from a path.
public static load Loads all remaining TOML text from a reader.
public static parse
parse(text as String) as SortedMap<String, Object> throws TOMLParseException:
Parses TOML text into its natural Klyn representation.
public static save
save(filename as String, document as Map<String, Object>) as Void throws IOException, TOMLWriteException:
Saves a root table to a UTF-8 file, replacing existing content.
public static save
save(path as Path, document as Map<String, Object>) as Void throws IOException, TOMLWriteException:
Saves a root table to a path, replacing existing content.
public static save
save(writer as TextWriter, document as Map<String, Object>) as Void throws IOException, TOMLWriteException:
Writes a root table to an existing text writer.
public static stringify
stringify(document as Map<String, Object>) as String throws TOMLWriteException:
Serializes a root table as deterministic TOML text.