mirror of https://github.com/tidwall/tile38.git
22 lines
461 B
Go
22 lines
461 B
Go
package json // import "layeh.com/gopher-json"
|
|
|
|
import (
|
|
"github.com/yuin/gopher-lua"
|
|
)
|
|
|
|
// Preload adds json to the given Lua state's package.preload table. After it
|
|
// has been preloaded, it can be loaded using require:
|
|
//
|
|
// local json = require("json")
|
|
func Preload(L *lua.LState) {
|
|
L.PreloadModule("json", Loader)
|
|
}
|
|
|
|
// Loader is the module loader function.
|
|
func Loader(L *lua.LState) int {
|
|
t := L.NewTable()
|
|
L.SetFuncs(t, api)
|
|
L.Push(t)
|
|
return 1
|
|
}
|