%dw 2.0
import * from dw::util::Tree
var myArray = [1, {name: ["", true], test: 213}, "123", null]
output application/json
---
{
a: myArray filterArrayLeafs ((value, path) ->
!(value is Null or value is String)),
b: myArray filterArrayLeafs ((value, path) ->
(value is Null or value == 1)),
c: { a : [1,2] } filterArrayLeafs ((value, path) ->
(value is Null or value == 1)),
d: myArray filterArrayLeafs ((value, path) ->
!isArrayType(path))
}
filterArrayLeafs
filterArrayLeafs(value: Any, criteria: (value: Any, path: Path) -> Boolean): Any
Applies a filtering expression to leaf or Path
values of an array.
The leaf values in the array 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 filterArrayLeafs
behaves with different
inputs.