I have a payload that I'm trying to flatten but haven't had much luck. The payload looks like:
{payload=
[xyz,
[{creation: 1501535135,
id: reference_1},
{creation: 225351535,
id: reference_2 }]
abc,
[{creation: 129495124,
id: reference_3},
{creation: 151352244,
id: reference_4 }]
[{creation: 1501535135,
id: reference_1},
{creation: 225351535,
id: reference }]
[{creation: 1501535135,
id: reference_3},
{creation: 225351535,
id: reference_4}]
]
}
The output I would like in the end is a single array with all the creation and id values, so something like:
{payload=
[{creation: 1501535135,
id: reference_1},
{creation: 225351535,
id: reference_2,
{creation: 1501535135,
id: reference_3},
{creation: 225351535,
id: reference_4}]
}
I tried a few different things, firstly I tried to transform it by filtering only one object type of array so that the strings (xyz, abc) get dropped:
singleArray: payload filter ((element, index) -> typeOf(element) == "array")
At which point I was going to flatten the payload. However, the filter was throwing an error.
typeOf(element) is Array