Skip to content
Plugins (183)

toml

stable

Lightweight TOML parser and serializer: parse a TOML string or file into a Zolo table, and convert a table back to a TOML string.

use plugin toml::{parse, stringify, parse_file}
3 functions Data Formats
Runs with the native Zolo host

Plugin snippets can be edited in the Playground, but native capabilities are executed locally with the Zolo CLI.

/ filter jk navigate Esc clear
Functions (3)
  1. parse Parse a TOML string into a table
  2. stringify Serialize a table to a TOML string
  3. parse_file Read and parse a TOML file from disk

From import to result

  1. 01Import only what you use
  2. 02Copy the smallest example
  3. 03Run it with the Zolo CLI

Parse a TOML string into a table

Parses a TOML-formatted string and returns it as a Zolo table. TOML arrays become integer-keyed tables; TOML tables become string-keyed tables. Datetime values are returned as strings.

use plugin toml::{parse}

let config = parse('[server]\nhost = "localhost"\nport = 8080')
print(config["server"]["host"])
print(config["server"]["port"])

Serialize a table to a TOML string

Serializes a Zolo table to a pretty-printed TOML string. Integer-keyed tables are serialized as TOML arrays; string-keyed tables become TOML tables.

use plugin toml::{parse, stringify}

let data = #{"name": "myapp", "version": "1.0", "debug": false}
let toml_str = stringify(data)
print(toml_str)

Read and parse a TOML file from disk

Reads the file at path and parses its contents as TOML. Raises an error if the file cannot be read or contains invalid TOML.

use plugin toml::{parse_file}

let config = parse_file("config/settings.toml")
print(config["database"]["url"])

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en