导入
protobuf.load(string)
读取编译完成后的protobuffer字符串
protobuf.loadfile(filename)
读取编译完成后的protobuffer文件
protobuf.encode(struct, table)
protobuf.decode(struct, string)
将string
按照字符串定义的格式进行反序列化.
protobuf.tohex(string)
将string
数据进行16进制格式打印.
protobuf.clear(struct)
清除struct
定义的结构体.
使用进行编译protoc Person.pb -o Person.lua
后得到文件Person.lua
.
运行script/test_protobuf.lua
中的示例代码查看效果:
输出结果: