IzonFreak
IzonFreak

Reputation: 409

Protobuf type and variant array types

I was looking at proto3 documentation and it is not clear to me if I can create an rule for my use case. The equivalent in c++ will be to have the following declaration:

 using Variant = std::variant<bool, int32_t, uint32_t, int64_t, uint64_t, float, double>;

 using Data = std::vector<std::vector<Variant>>;

Is it possible to describe "Data" using protobuf? From my understanding think it should probably be something like "repeated repeated Any".

Upvotes: 1

Views: 708

Answers (1)

for_stack
for_stack

Reputation: 22886

You cannot have a repeated repeated Any. Try the following code:

message SubData {
    repeated google.protobuf.Any element = 1;
}

message Data {
    repeated SubData sub_data = 1;
}

Upvotes: 1

Related Questions