---
schema_version: "1"
id: 4b2f29e2b140058e4d6b657a3f08a64183fa9cd65f700bdac735f4632e05fe4c
title: mapLeafValues
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-tree-functions-mapleafvalues.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-tree-functions-mapleafvalues
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 30411af8893324aba59e5c0a8076dcdc3ada22ea0ae5969a0cac74f9e42b46e5
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

# mapLeafValues

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

## mapLeafValues(value: Any, callback: (value: Any, path: Path) -> Any): Any

Maps the terminal (leaf) nodes in the tree.

Leafs nodes cannot have an object or an array as a value.

_Introduced in DataWeave version 2.2.2._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>value</code></p></td><td><p>The value to map.</p></td></tr><tr><td><p><code>callback</code></p></td><td><p>The mapper function.</p></td></tr></tbody></table>

### Example

This example transforms all the string values to upper case.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Tree
output application/json
---
 {
     user: [{
         name: "mariano",
         lastName: "achaval"
     }],
     group: "data-weave"
 } mapLeafValues (value, path) -> upper(value)
```

#### Output

```Json
{
   "user": [
     {
       "name": "MARIANO",
       "lastName": "ACHAVAL"
     }
   ],
   "group": "DATA-WEAVE"
 }
```

### Example

This example returns a new value for an object, array, or attribute.

#### Source

```DataWeave
%dw 2.0
output application/json
import * from dw::util::Tree
---
{
    name: "Mariano",
    test: [1,2,3]
} mapLeafValues ((value, path) -> if(isObjectType(path))
                                        "***"
                                  else if(isArrayType(path))
                                        "In an array"
                                  else "Is an attribute")
```

#### Output

```Json
{
  "name": "***",
  "test": [
    "In an array",
    "In an array",
    "In an array"
  ]
}
```
