Skip to content

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?



  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.