Dice roller by CSS and jQuery
19/02/2022
In DataWeave 2.0 (Mule 4.2), you can’t use the recursive update operator, but you still have powerful tools for reshaping data. The pluck operator lets you iterate over an Object’s key – value pairs and return a clean Array – perfect for further array-based processing (filter, map, slice, etc.).
value: the field’s valuekey: the field’s nameindex: position in the resulting Array<expression>: any DataWeave expression that returns one element of the new ArraySuppose you have sales counts per product:
To turn this into an Array of { product, count } objects:
Result:
mapObject logic.When you need to break an Object into an Array of custom records in DataWeave 2.0, reach for pluck. It keeps your code concise, clear, and fully leverages the Array transformations that follow.