Challenge - creating an object wrapped into an array using inline functions ONLY

:bullseye: What is your goal?

As the title says, my goal is to create an object (collection) wrapped in an array only using inline functions. I know about iterator/aggregator solutions - the goal is to avoid these to save operations.

For more context - I have value from a webhook that looks like this:

“emailAddress”: “not@yourmom.com”

I need to create an output like this:

[
{
“label”: null,
“value”: “not@yourmom.com”
}
]

Please note this is an object wrapped in an array.

I have no problem creating the object like this:

{
“label”: null,
“value”: “not@yourmom.com”
}

However, I have not been able to wrap it into an array.

I appreciate any hints on how to do this. Thanks in advance.

:thinking: What is the problem & what have you tried?

I have tried multiple combinations of all possible array functions to no avail.

The Array Aggregator Module counts 1 ops per execution regardless of how many items are in the resulting array. So just add it after the Webhook module.

The webhook sends a bunch of parameters within a collection. I need to take one out, create a collection around it and wrap it in an array. I know I could create an array using an iterator an then aggregate it but it is a waste of 2 operations. That’s for each parameter I need to process this way.

Nevermind, I solved this myself, the result formula follows:

{{if(1.emailAddress = null; emptyarray; add(emptyarray; toCollection(add(emptyarray; add(emptyarray; “label”; null); add(emptyarray; “value”; 1.emailAddress)); 1; 2)))}}

2 Likes