Getting started Community Training Tutorials Documentation APIs, AI & Tools
%dw 2.0
import * from dw::core::Objects
output application/json
var obj = {
"a": 1,
"b": 2,
"c": 5,
"d": 1
}
---
obj takeWhile ((value, key) -> value < 3)
You're viewing an older version of the documentation. You can switch to the latest version or use the version selector in the left navigation.
Selects key-value pairs from the object while the condition is met.
Introduced in DataWeave version 2.3.0.
| Name | Description |
|---|---|
|
The object to filter. |
|
The condition (or expression) used to match a key-value pairs in the object. |
This example iterates over the key-value pairs in the object and selects the elements while the condition is met. It outputs the result into an object.