1

ArrayList corresponds to repeated string:

message m1 {
    repeated string mylist = 1;
}

How to define ArrayList< ArrayList< String> > in message? Thanks!

Feihua Fang
  • 931
  • 1
  • 8
  • 15

1 Answers1

2

You'll need another message to represent the inner List.

message M1 {
  repeated M2 mylist = 1;
}

message M2 {
  repeated string mylist = 1;
}

Of course, you may add as many fields as you'd like to M2, and you'll need some separate conversion logic to assemble the List<M2> into an ArrayList<ArrayList<String>>.

You may even want to create a reusable message to represent a list of strings:

message M1 {
  repeated StringList mylist = 1;
}

message StringList {
  repeated string value = 1;
}
Jeff Bowman
  • 90,959
  • 16
  • 217
  • 251