Skip to content
Advertisement

google protobuffer how to define list of lists in proto file?

I have a class with a list of lists field as below:

public class MyClass{
   private List<List<String>>
}

how to define it in a proto file?

Advertisement

Answer

  1. You can declare your own “types” in proto files called message.
  2. If you’d like to declare a list you should use repeated keyword.

Combining those two gives us:

message ListOfListsOfStrings {
    repeated ListOfStrings listOfStrings=1;
}

message ListOfStrings {
    repeated string strings=1;
}

You can then use ListOfListsOfStrings message in your proto were appropriate.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement