---
schema_version: "1"
id: e7ba1830d23d75ef178f15856cdef23b85c365b426484cf92a3cd0dc32cc9fa9
title: filterObjectLeafs
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-tree-functions-filterobjectleafs.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-tree-functions-filterobjectleafs
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 0e41adec15a551a1b7907ca4063e5368f93fad708a9eebf42360668d4dff66db
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# filterObjectLeafs

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

## filterObjectLeafs(value: Any, criteria: (value: Any, path: Path) -> Boolean): Any

Applies a filtering expression to leaf or `Path` values of keys in an object.

The leaf values in the object must be `SimpleType` or `Null` values. See
[Core Types](https://docs.mulesoft.com/dataweave/latest/dw-core-types) for descriptions of the
types.

_Introduced in DataWeave version 2.4.0._

### 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>An input value of <code>Any</code> type.</p></td></tr><tr><td><p><code>criteria</code></p></td><td><p>Boolean expression to apply to <code>SimpleType</code> or <code>Null</code> leaf values of all objects in the input <code>value</code>. If the result is <code>true</code>, the object retains the leaf value and its key. If not, the function removes the leaf value and key from the output.</p></td></tr></tbody></table>

### Example

This example shows how `filterObjectLeafs` behaves with different inputs.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Tree
var myArray = [{name @(mail: "me@me.com", test:123 ): "", id:"test"},
               {name: "Me", id:null}]
output application/json
---
{
 a: {
     name: "Mariano",
     lastName: null,
     age: 123,
     friends: myArray
    }  filterObjectLeafs ((value, path) ->
         !(value is Null or value is String)),
 b: { c : null, d : "hello" } filterObjectLeafs ((value, path) ->
         (value is Null and isObjectType(path)))
}
```

#### Output

```Json
{
  "a": {
    "age": 123,
    "friends": [
      {

      },
      {

      }
    ]
  },
  "b": {
    "c": null
  }
}
```
