I usually use fromJSON to get the target:
ll <- fromJSON('[[[1,2],[3,4],[5,6]]]') str(ll) List of 1 $ :List of 3 ..$ : num [1:2] 1 2 ..$ : num [1:2] 3 4 ..$ : num [1:2] 5 6
So, we must create a list of unnamed lists, each of which contains 2 elements:
xx <- list(setNames(split(1:6,rep(1:3,each=2)),NULL)) identical(toJSON(xx),'[[[1,2],[3,4],[5,6]]]') [1] TRUE
source share