mwild
mwild

Reputation: 1655

GRPC nested arrays (protobuf3)

Im using GRPC with proto3 and im trying to represent the following JSON in messages:

    menus: [
        { name: "Mains",
          contents: [
              {
                  title: "Steaks",
                  contents: [
                      {name: "Sirloin", price: 4.99},
                      {name: "Rump", price: 8.99}
                  ]
              }
          ]
    ]

As you can see there are 3 levels of arrays. My attempt at representing this in protobuf is:

    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;
    }

When I attempt to run a call that returns this message type I receive the following error:

   .menu.contentItem#__parentArray is not a field: undefine

I believe this is to do with the nested arrays but it could be something that Im not noticing.

Any ideas as to why this doesnt work?

Upvotes: 3

Views: 1333

Answers (0)

Related Questions