---
schema_version: "1"
id: 19be04d6452504f91d1321ffee9f011e7f21a87b97ac9a35935fa7273c589869
title: filterObjectLeafs
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dw-tree-functions-filterobjectleafs.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dw-tree-functions-filterobjectleafs
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 3bcf38fb367d8e4a9e4332171dce969b0aaffc3f16bd202e005919de2f6a4a8b
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
---

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