---
schema_version: "1"
id: ef5521abf2f87b279a90707099a5b218c4684e8ecb381ae516d9e58f7cccc47d
title: filterTree
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.7/dw-tree-functions-filtertree.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.7/dw-tree-functions-filtertree
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 972f64283d80297e6f3d3d0253ce8537e35e66dc7e53252aac55b4a5e49b2e91
description: MuleSoft Documentation Site
release: "2.7"
latest: false
---
# filterTree

## [](#filtertree1)filterTree(value: Any, criteria: (value: Any, path: Path) -> Boolean): Any

指定された ​`criteria`​ に基づいて入力内のノードの値またはパスを絞り込みます。

この関数では、入力内のノードを反復処理します。​`criteria`​ は入力内の値またはパスに適用できます。​`criteria`​ が ​`true`​ に評価される場合、ノードは出力に留まります。​`false`​ の場合、この関数によってノードが除外されます。

_DataWeave バージョン 2.4.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>value</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>criteria</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ノードを絞り込むかどうかを判断する式。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、さまざまな入力での ​`filterTree`​ の動作を示します。 出力はデモを目的とした ​`application/dw`​ となります。

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

```DataWeave
%dw 2.0
import * from dw::util::Tree
output application/dw
---
{
    a: {
          name : "",
          lastName @(foo: ""): "Achaval",
          friends @(id: 123): [{id: "", test: true}, {age: 123}, ""]
        } filterTree ((value, path) ->
            value match  {
                            case s is String -> !isEmpty(s)
                            else -> true
                          }
    ),
    b: null filterTree ((value, path) -> value is String),
    c: [
            {name: "Mariano", friends: []},
            {test: [1,2,3]},
            {dw: ""}
        ] filterTree ((value, path) ->
            value match  {
                            case a is Array ->  !isEmpty(a as Array)
                            else -> true
                        })
}
```

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

```DataWeave
{
  a: {
    lastName: "Achaval",
    friends @(id: 123): [
      {
        test: true
      },
      {
        age: 123
      }
    ]
  },
  b: null,
  c: [
    {
      name: "Mariano"
    },
    {
      test: [
        1,
        2,
        3
      ]
    },
    {
      dw: ""
    }
  ]
}
```