cancel
Showing results for 
Search instead for 
Did you mean: 

Convert array of objects in an object of key value pairs

Max
New Contributor II

Hello,

I need to convert the following array of object into an object of key value pairs.

Input:

Screenshot 2024-01-24 at 4.40.52 PM.png

Expected output:

Screenshot 2024-01-24 at 4.44.39 PM.png

Thank you for your help!

1 REPLY 1

ivicakoteski
New Contributor III

Hi @Max ,

You can try the reduce function in the mapper snap. You'll need to set {} (an empty object) as the initialElement and apply the extend function to put all array elements into the initialized empty object.

$ranges.reduce((accum, currentValue) => accum.extend(currentValue), {})

ivicakoteski_0-1706174256743.png

Hope this helps!

BR.