在go中使用lua示例, 基于gopher-lua!
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
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
}