在go中使用lua示例, 基于gopher-lua!
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

31 行
498 B

package json
import (
lua "github.com/yuin/gopher-lua"
)
func Decode(L *lua.LState) int {
str := L.CheckString(1)
value, err := ValueDecode(L, []byte(str))
if err != nil {
L.Push(lua.LNil)
L.Push(lua.LString(err.Error()))
return 2
}
L.Push(value)
return 1
}
func Encode(L *lua.LState) int {
value := L.CheckAny(1)
data, err := ValueEncode(value)
if err != nil {
L.Push(lua.LNil)
L.Push(lua.LString(err.Error()))
return 2
}
L.Push(lua.LString(string(data)))
return 1
}