Protocol buffers protobuf:定义父项<-&燃气轮机;儿童关系
我如何在proto中定义父母与孩子的关系Protocol buffers protobuf:定义父项<-&燃气轮机;儿童关系,protocol-buffers,proto3,Protocol Buffers,Proto3,我如何在proto中定义父母与孩子的关系 syntax = "proto3"; message Root { repeated Category category = 2; } message Category { string name = 2; repeated Category parent = 3; } 这里的关键是我希望能够召唤孩子们 MamyCategoryInstance | |--- FooCategoryInstance ...//
syntax = "proto3";
message Root {
repeated Category category = 2;
}
message Category {
string name = 2;
repeated Category parent = 3;
}
这里的关键是我希望能够召唤孩子们
MamyCategoryInstance
|
|--- FooCategoryInstance
...//
PapaCategoryInstance
|
|---- FooCategoryInstance
|---- BarCategoryInstance
谢谢你你不能。协议缓冲区是基于“树”的序列化程序,而不是基于“图”的序列化程序。因此,对象只有一个语义父对象,这是隐式的,而不是显式的。意思是:
消息根目录{
重复类别=2;
}
消息类别{
字符串名称=2;
}
每个类别的父级很简单:在树中哪个节点在它上面。如果尝试创建显式父关系,序列化将由于递归而失败