9951 explained code solutions for 126 technologies


luaHow to save table to YAML


local yml = require "lyaml"
local yml_str = yml.dump({tbl})ctrl + c
require "lyaml"

loads lyaml module to work with YAML format

yml.dump

converts given table into string

tbl

sample table to convert to string

yml_str

resulting string variable will contain YAML string


Usage example

local yml = require "lyaml"
local tbl = {people={name="Donald"}}
print(yml.dump({tbl}))
output
---
people:
  name: Donald
...