Skip to content

Instantly share code, notes, and snippets.

Created April 3, 2016 03:50
Show Gist options
  • Save anonymous/1fd2e1f09d5622667705028da514f531 to your computer and use it in GitHub Desktop.
Save anonymous/1fd2e1f09d5622667705028da514f531 to your computer and use it in GitHub Desktop.
local sproto = require "sproto"
local print_r = require "print_r"
local sp = sproto.parse [[
.foobar {
.nest {
a 1 : string
b 3 : boolean
c 5 : integer
}
a 0 : string
b 1 : integer
c 2 : boolean
d 3 : *nest(a)
e 4 : *string
f 5 : *integer
g 6 : *boolean
h 7 : *foobar
}
]]
local obj = {
d = {
},
e = {},
f = {},
g = {},
h = {
},
}
local code = sp:encode("foobar", obj)
fh = io.open("test_empty", "w")
fh:write(code)
obj = sp:decode("foobar", code)
print_r(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment