yaml.encode(value)function

Encodes the given Lua table into a YAML string.

This function supports sequences (table with integer keys), mappings (tables with string keys), multiple documents (when given an array of tables), and preserves types following this rules :

Lua value type YAML
"string" "string"
number
boolean
table (non array)
table (integer keys)
yaml.null
object
thread
userdata

Parameters

value

The Lua table to encode to YAML string.

Return value

Returns the YAML representation as a string.

Example

--! luart-extensions import yaml local t = {name = "Alice", age = 30} local ystr = yaml.encode(t) print(ystr)