Question on $zip argument
robinmackenzie opened this issue · 0 comments
robinmackenzie commented
With:
$zip([1, 2, 3], [4, 5, 6], [7, 8, 9])
It produces the expected result:
[
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
]
How should it work here for example:
(
$arr := [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
$zip($arr);
)
Which produces:
[
[
[1, 2, 3]
],
[
[4, 5, 6]
],
[
[7, 8, 9]
]
]
?
My use case is that the array I want to pass to $zip will have an unknown number of inner arrays.
I'm using the JSONata Exerciser v2.0.2.
Noting that I did look here:
Lines 1570 to 1593 in b520b88
And realised if I was using javascript then I could use the spread syntax:
const arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
const result = zip(...arr);
But researching the documentation/ stack overflow etc - I didn't see a way to do that with jsonata syntax.
Thanks in advance.