Forum Discussion
Hey @jpsheff,
This can be achieved by using the .reduce() function. After you transform the parameter to an object field, use the following expression:
$parameters.reduce((acc,curr)=> acc.replaceAll(curr.name,curr.value),$string1)
Here’s a pipeline with the exact samples you provided, that does the transformation:
Replace string values from Array_2022_02_22.slp (5.3 KB)
I would suggest not to pass the JSON object as a parameter, if possible.
Regards,
Bojan
- Aleksandar_A2 years agoContributor III
Hello lake,
You can iterate through one of the arrays using either map or filter (depends on what you want as an output) and check if the current element is present in the second array.
Example input:
[ { "arr1": [ 1, 2, 3, 4, 5, 6 ], "arr2": [ 3, 4, 5, 6, 7, 8 ] } ]
Using map:
$arr1.map(x => {"elem": x,"found": $arr2.indexOf(x) != -1})
"compare": [ { "elem": 1, "found": false }, { "elem": 2, "found": false }, { "elem": 3, "found": true }, { "elem": 4, "found": true }, { "elem": 5, "found": true }, { "elem": 6, "found": true }
Using filter:
$arr1.filter(x => $arr2.indexOf(x) != -1)
"present": [ 3, 4, 5, 6 ]
You can refer to the attached pipeline and let me know if it helps you.
Regards,
Aleksandar.
Related Content
- 8 years ago