Protocol buffers GRPC嵌套数组(protobuf3)
Im使用GRPC和proto3,并尝试在消息中表示以下JSON:Protocol buffers GRPC嵌套数组(protobuf3),protocol-buffers,grpc,proto,protobuf-3,Protocol Buffers,Grpc,Proto,Protobuf 3,Im使用GRPC和proto3,并尝试在消息中表示以下JSON: menus: [ { name: "Mains", contents: [ { title: "Steaks", contents: [ {name: "Sirloin", price: 4.99},
menus: [
{ name: "Mains",
contents: [
{
title: "Steaks",
contents: [
{name: "Sirloin", price: 4.99},
{name: "Rump", price: 8.99}
]
}
]
]
如您所见,有3个级别的阵列。我试图在protobuf中表示这一点:
message product {
string name = 2;
double price = 4;
}
message contentItem {
string title = 1;
repeated product products = 2;
}
message GetReply {
string name = 2;
repeated contentItem contents = 5 [packed=true];
}
message GetAllReply {
repeated GetReply menus = 1;
}
当我尝试运行返回此消息类型的调用时,我收到以下错误:
.menu.contentItem#__parentArray is not a field: undefine
我相信这和嵌套数组有关,但我可能没有注意到
关于为什么这不起作用,你有什么想法吗?在JSON中,
牛排之后的内容是否应该是产品
。虽然我最终发现我的错误与mongo有关