在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
syntax = "proto2";
package PB;
message Item
{
required string name = 1;
}
message Role
{
required string name = 1;
optional string email = 2;
repeated string t =3;
repeated Item item1 = 4;
optional Item item2 =5;
}
lua中解析 required optional repeated 类型 require "proto.player_pb"
local role = player_pb.Role()
role.name="444" --require字段
role.email ="eiail2222222" --optional
role.t:append("111") --repeated 基本类型
local tt =role.item1:add() -- repeated 嵌套类 复合类型
tt.name ="555"
role.item2.name = "6666" -- optional 嵌套类 复合类型
local pb_data1 = role:SerializeToString()
local msg = player_pb.Role()
msg:ParseFromString(pb_data1)
print(msg.email.." "..msg.item1[1].name.." "..msg.item2.name)
|
请发表评论