DZone

Main Points

  • The mapObject takes an object as an input and outputs an object
  • The mapObject transforms each key/value pair in the object

What Is the mapObject Function Used For?

The mapObject function is used to transform the data contained in an object, in the same way that the map function transforms the elements of an array. It does this by iterating over each key/value pair in the object and applying a transformation to each key and value. The result of each transformation is formed into an object.

How Is the Transformation Described?

The transformation that is applied to each key and value is described with a DataWeave script. For example, you can refer to the key, value, and index of the object to be transformed in the DataWeave script and apply a transformation such as the upper() function.

Source: DZone