---
schema_version: "1"
id: 9d9b3755dc33fb9dfe0cea28eb44a743863290839e065bf2e7a2aefbe5a0f222
title: takeWhile
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-objects-functions-takewhile.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-objects-functions-takewhile
source_site: docs.mulesoft.com
content_type: documentation
content_hash: dd1937d4853978e7a79adc69266a9da99ad22decf10db8aedf53a3bfe01d8761
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# takeWhile

## [](#takewhile1)takeWhile<T>(obj: Object, condition: (value: Any, key: Key) -> Boolean): Object

条件を満たす場合、オブジェクトからキー - 値ペア選択します。

_DataWeave バージョン 2.3.0 で導入されました。_

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>obj</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">絞り込むオブジェクト。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>condition</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">オブジェクトのキー - 値ペアの照合に使用される条件 (式)。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、オブジェクト内のキー - 値ペアを反復処理し、条件を満たす場合は要素を選択します。 結果はオブジェクトに出力されます。

#### [](#ソース)ソース

```DataWeave
%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)
```

#### [](#出力)出力

```json
{
  "a": 1,
  "b": 2
}
```