Contact Us 1-800-596-4880


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 for descriptions of the types.

Introduced in DataWeave version 2.4.0.


Name Description


An input value of Any type.


Boolean expression to apply to SimpleType or Null leaf values of all objects in the input value. If the result is true, the object retains the leaf value and its key. If not, the function removes the leaf value and key from the output.


This example shows how filterObjectLeafs behaves with different inputs.


%dw 2.0
import * from dw::util::Tree
var myArray = [{name @(mail: "", 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)))


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


  "b": {
    "c": null