local yaml = require("yaml")
local inspect = require("inspect")
-- yaml.decode()
local text = [[
a:
b: 1
]]
local result, err = yaml.decode(text)
if err then error(err) end
print(inspect(result, {newline="", indent=""}))
-- Output:
-- {a = {b = 1}}
state := lua.NewState()
Preload(state)
inspect.Preload(state)
source := `
local yaml = require("yaml")
local inspect = require("inspect")
local text = [[
a:
b: 1
]]
local result, err = yaml.decode(text)
if err then error(err) end
print(inspect(result, {newline="", indent=""}))
`
if err := state.DoString(source); err != nil {
log.Fatal(err.Error())
}