I have 3 array properties of varying length but all of the elements inside are of the same type. How do I combine all 3 into 1 large array property of 16 length?
I would use my Integration Toolkit's flatten() function, like so:
flatten(
asList(
{view.custom.CUB_Instances},
{view.custom.PDC_Instances},
{view.custom.USS_Instances}
)
)
Would this work if I have arrays inside of arrays?
It isn't recursive. The flatten() function converts a list-of-lists into a list, without going deeper.
Only jython can handle recursion.
I'm pretty sure the script transform to do this would literally just be:
return self.custom.CUB_Instances + self.custom.PDC_Instances + self.custom.USS_Instances
At least, I think that would work.
I wonder if it's worth overloading the expression language + operator to do concatenation of structures like this, only for document/JSON-like things. Probably not worth the risk of confusion, but maybe...
Seems an elegant solution. I like elegant solutions.
Late response, but is there a way to combine arrays via expression language rather than transforms?
Yes, if you install my Integration Toolkit. The asPairs() function will blindly concatenate arrays (even if they aren't lists of pairs).
