Created
April 3, 2016 03:50
-
-
Save anonymous/1fd2e1f09d5622667705028da514f531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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