%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)))
}
filterObjectLeafs
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.
Parameters
Name | Description |
---|---|
|
An input value of |
|
Boolean expression to apply to |
Example
This example shows how filterObjectLeafs
behaves with different inputs.