我正在使用GRPC和proto3,我试图在消息中表示以下JSON:
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
我相信这与嵌套数组有关,但它可能是我没注意到的。
关于为什么这不起作用的任何想法?