You can simply return a List<List<String>> to get an array of arrays in json but you won't have the names and you'll have to be based on the order:
@RestController
public class MyController {
@RequestMapping(path = "/hello")
public List<List<String>> path() {
List<String> l1 = Arrays.asList("l11","l12","l13");
List<String> l2 = Arrays.asList("l21","l22","l23");
List<String> l3 = Arrays.asList("l31","l32","l33");
return Arrays.asList(l1,l2,l3);
}
}
Result: [["l11","l12","l13"],["l21","l22","l23"],["l31","l32","l33"]]
or alternatively create a DTO encapsulating these and return it directly to get a json object including the param names:
@RestController
public class MyController {
@RequestMapping(path = "/hello")
public DTO path() {
List<String> l1 = Arrays.asList("l11","l12","l13");
List<String> l2 = Arrays.asList("l21","l22","l23");
List<String> l3 = Arrays.asList("l31","l32","l33");
return new DTO(l1,l2,l3);
}
public static class DTO {
private final List<String> l1;
private final List<String> l2;
private final List<String> l3;
public DTO(List<String> l1, List<String> l2, List<String> l3) {
this.l1 = l1;
this.l2 = l2;
this.l3 = l3;
}
public List<String> getL1() {
return l1;
}
public List<String> getL2() {
return l2;
}
public List<String> getL3() {
return l3;
}
}
}
Result:
{"l1":["l11","l12","l13"],"l2":["l21","l22","l23"],"l3":["l31","l32","l33"]}