cancel
Showing results for 
Search instead for 
Did you mean: 

Change nested arrays into one array

Dawid_Zajdel
New Contributor

Hi,

I have a situation like below:

image

I have array "Allowance_Plan’ and in this array I could have many elements which also are arrays.
Child arrays as a elements contains objects.

In this case I have 2 arrays with 2 object in each of them.

As a final result I would like to receive one array “Allowance_Plan” which contains 4 objects. (2 from first child array and 2 from second child array)
Please suggest how to solve this problem.

1 ACCEPTED SOLUTION

tstack
Former Employee

I think you’re looking for the .concat() method on arrays. That method will concatenate its arguments into a single array. To pass the arrays as the arguments to the method, you can use the spread operator (...), like so:

[].concat(...$['peci:Allowance_Plan'])

Here’s an example pipeline:

Community7041_2020_03_09.slp (3.5 KB)

View solution in original post

1 REPLY 1

tstack
Former Employee

I think you’re looking for the .concat() method on arrays. That method will concatenate its arguments into a single array. To pass the arrays as the arguments to the method, you can use the spread operator (...), like so:

[].concat(...$['peci:Allowance_Plan'])

Here’s an example pipeline:

Community7041_2020_03_09.slp (3.5 KB)