Forum Discussion

Max's avatar
Max
New Contributor II
2 years ago

Convert array of objects in an object of key value pairs

Hello,

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

Input:

Expected output:

Thank you for your help!

1 Reply

  • ivicakoteski's avatar
    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), {})

    Hope this helps!

    BR.