Closed sjnam closed 8 years ago
About 1, can you provide the command you run and the error message?
About 2, id should be a string. Why do you think it should be an integer?
luajit: /usr/local/share/lua/5.1/capnp/compile.lua:1184: imported file "enums.capnp" is missing, compile it together withother Cap'n Proto files
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/capnp/compile.lua:1184: in function 'check_import'
/usr/local/share/lua/5.1/capnp/compile.lua:1162: in function 'comp_body'
/usr/local/share/lua/5.1/capnp/compile.lua:1294: in function 'compile'
stdin:71: in main chunk
[C]: at 0x01000013f0
lua: plugin failed: exit code 1
2. you defined id by UInt32.
id @0 :UInt32;
and if id is string then I got result
{"people":[{"id":0,"employment":{"school":"MIT"},"email":"alice@example.com","name":"Alice","phones":[{"number":"555-1212","type":"MOBILE"}]},{"id":0,"employment":{"unemployed":"Void"},"email":"bob@example.com","name":"Bob","phones":[{"number":"555-4567","type":"HOME"},{"number":"555-7654","type":"WORK"}]}]}
the json id is 0
Yes, the document is old. You do need to compile all the schema files together like this:
$ capnp compile -olua proto/example.capnp proto/enums.capnp proto/lua.capnp proto/struct.capnp
Nice catch, thanks.
Merged, thanks!
1. after install lua-capnproto by luarocks, the following test does not work.
2. File main.lua of example directory id should be interger not string.