Skip to content

kohkimakimoto/gluayaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gluayaml

Yaml parser for gopher-lua

Installation

go get github.com/kohkimakimoto/gluayaml

API

yaml.parse(string)

Parses yaml formatted string and returns a table. If this function fails, it returns nil, plus a string describing the error.

Usage

package main

import (
	"github.com/yuin/gopher-lua"
	"github.com/kohkimakimoto/gluayaml"
)


func main() {
	L := lua.NewState()
	defer L.Close()

	L.PreloadModule("yaml", gluayaml.Loader)
	if err := L.DoString(`
local yaml = require("yaml")
local str = [==[
key1: value1
key2:
  - value2
  - value3
]==]

local tb = yaml.parse(str)
print(tb.key1)    -- value1
print(tb.key2[1]) -- value2
print(tb.key2[2]) -- value3
`); err != nil {
		panic(err)
	}
}

Author

Kohki Makimoto [email protected]

License

MIT license.

About

Yaml parser for gopher-lua

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages