---
schema_version: "1"
id: 617a935a3ac9f9afeb18f8395b9e830555bde70de6b7a2e3fdd8c358df064d2e
title: Map Objects
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dataweave-cookbook-map-an-object.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-map-an-object
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 15894c903727a48044076d14a4c5c094bea8c8edb99cdec78a30c7c0e98389db
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
keywords: studio, anypoint, transform, transformer, format, aggregate, rename, split, filter convert, json, metadata, dataweave, data weave, datamapper, dwl, dfl, dw, output structure, input structure, map, mapping, as
---

# Map Objects

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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:

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

Input JSON Payload:

```json
{
  "books": [
    {
      "-category": "cooking",
      "title": "Everyday Italian",
      "author": "Giada De Laurentiis",
      "year": "2005",
      "price": "30.00"
    },
    {
      "-category": "children",
      "title": "Harry Potter",
      "author": "J K. Rowling",
      "year": "2005",
      "price": "29.99"
    },
    {
      "-category": "web",
      "title": "XQuery Kick Start",
      "author": [
        "James McGovern",
        "Per Bothner",
        "Kurt Cagle",
        "James Linn",
        "Vaidyanathan Nagarajan"
      ],
      "year": "2003",
      "price": "49.99"
    },
    {
      "-category": "web",
      "-cover": "paperback",
      "title": "Learning XML",
      "author": "Erik T. Ray",
      "year": "2003",
      "price": "39.95"
    }
  ]
}
```

Output JSON:

```json
{
  "items": [
    {
      "book": {
        "-CATEGORY": "cooking",
        "TITLE": "Everyday Italian",
        "AUTHOR": "Giada De Laurentiis",
        "YEAR": "2005",
        "PRICE": "30.00"
      }
    },
    {
      "book": {
        "-CATEGORY": "children",
        "TITLE": "Harry Potter",
        "AUTHOR": "J K. Rowling",
        "YEAR": "2005",
        "PRICE": "29.99"
      }
    },
    {
      "book": {
        "-CATEGORY": "web",
        "TITLE": "XQuery Kick Start",
        "AUTHOR": [
          "James McGovern",
          "Per Bothner",
          "Kurt Cagle",
          "James Linn",
          "Vaidyanathan Nagarajan"
        ],
        "YEAR": "2003",
        "PRICE": "49.99"
      }
    },
    {
      "book": {
        "-CATEGORY": "web",
        "-COVER": "paperback",
        "TITLE": "Learning XML",
        "AUTHOR": "Erik T. Ray",
        "YEAR": "2003",
        "PRICE": "39.95"
      }
    }
  ]
}
```

## Related Examples

- [Map Data with DataWeave](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-map)

- [Map Object Elements as an Array](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-map-object-elements-as-an-array)

- [Extract Data](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-extract-data)

- [Transform XML to JSON](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-perform-basic-transformation)

- [Rename Keys](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook-rename-keys)

## See Also

- [DataWeave Types](https://docs.mulesoft.com/dataweave/2.3/dataweave-types)

- [DataWeave Selectors](https://docs.mulesoft.com/dataweave/2.3/dataweave-selectors)

- [DataWeave Cookbook](https://docs.mulesoft.com/dataweave/2.3/dataweave-cookbook)
