Forum Discussion

fkhan060's avatar
fkhan060
New Contributor II
4 years ago
Solved

Extend Object by Dynamically Adding columns based on delimited string

I have the following Input: [ { “Customer Super Key”: “CUST-XXX”, “Customer Security Segment”: “BU00172;BU00173;BU00174;BU00176;BU00175” } ] I want to transform it to: [ { “Custom...
  • fkhan060's avatar
    fkhan060
    4 years ago

    Thank you CJ!, that did the trick but it I also had to add an $.extend at the root level to achieve what I was going for, so my finally expression ended up looking like this in the mapper Snap:

    $.extend($[‘Customer Security Segment’].split(“;”).reduce((accum, curVal, index) => accum.extend({["Customer Security Segment " + (index + 1)]: curVal }), {}))