TOML
TOML 库。
Static ClassAPI Source
🎒 示例
(TOML.Dump) Stringifies a Lua table
local encoded_value = TOML.Dump({ 1, 2, 3, { x = 10, y = Vector(1, 2, 3) }, "he" })
-- Outputs "[ 1, 2, 3, { y = "Vector(1.000000, 2.000000, 3.000000)", x = 10 }, "he" ]"
(TOML.Parse) Parses a TOML string into a Lua table
local decoded_value = TOML.Parse("my_table = [ 1, 2, 3 ]")
-- Outputs "the table { ["my_table"] = { [1] = 1, [2] = 2, [3] = 3 } }"
🗿 静态函数
Dump
返回一个表示以 TOML 编码的值的字符串
local ret = TOML.Dump(value)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| table | value | Required parameter | 将要转换为 TOML 的表 |
Returns
| Type | Description |
|---|---|
| string | TOML 格式的表 |
TOML.Dump Examples
Stringifies a Lua table
local encoded_value = TOML.Dump({ 1, 2, 3, { x = 10, y = Vector(1, 2, 3) }, "he" })
-- Outputs "[ 1, 2, 3, { y = "Vector(1.000000, 2.000000, 3.000000)", x = 10 }, "he" ]"
Parse
返回一个表示解码后的 TOML 字符串的值
local ret = TOML.Parse(value)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | value | Required parameter | 将要转换为表的 TOML |
Returns
| Type | Description |
|---|---|
| any | 转换为表的 TOML |
TOML.Parse Examples
Parses a TOML string into a Lua table
local decoded_value = TOML.Parse("my_table = [ 1, 2, 3 ]")
-- Outputs "the table { ["my_table"] = { [1] = 1, [2] = 2, [3] = 3 } }"