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

# 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"
  ]
}
```
