Contact Us 1-800-596-4880

Map Objects

This DataWeave example uses both the map and mapObject functions to iterate through the input and set all of the keys to upper case.

The example uses these DataWeave functions:

  • map to go through the elements in the "books" array.

  • mapObject to go through the keys and values in each of the objects of the array.

  • upper to set each key to upper case.

DataWeave Script:
%dw 2.0
output application/json
---
items: payload.books map (item, index) -> {
      book: item mapObject (value, key) -> {
      (upper(key)): value
      }
}
dataweave
Input JSON Payload:
Output JSON: