Forum Discussion
The extend() method on objects can help you construct objects dynamically. You can pass it an array of key/value pairs and it will create a new object containing the values from the original object plus whatever was specified by the pairs.
In your case, I think you can create the pairs by doing a map over the customDataSets array, like so:
$customDataSets.map(x => [x.customData.name, x.customData.value])
You can then extend the original input doc, to create a new doc containing the original stuff, plus the custom keys:
$.extend($customDataSets.map(x => [x.customData.name, x.customData.value]))
Use a target path of ‘$’ to pass the object as the whole output. But, it looks like you’ll need another mapper to delete the customDataSets if you do that.