---
schema_version: "1"
id: 148113f9a897059871343389788a2678381604d1b6aa72ddba0552fbf8b901bf
title: keysOf
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.3/dw-core-functions-keysof.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.3/dw-core-functions-keysof
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5ea4d0a7b5987d336212a10e79d9641d6689c722d9058f2327fceecc34b6584d
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# keysOf

## [](#keysof1)keysOf(Object): Array<Key>

入力オブジェクト内のキー - 値ペアからのキーの配列を返します。

返されるキーは Key (キー) 型に属します。各キーを文字列として返すには、代わりに ​`namesOf`​ を使用します。

_DataWeave 2.3.0 で導入されました。Mule 4.3 以降でサポートされます。_​

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

<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>object</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">評価するオブジェクト。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、入力オブジェクト内のキー - 値ペアからのキーを返します。

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

```DataWeave
%dw 2.0
output application/json
---
{ "keysOf" : keysOf({ "a" : true, "b" : 1}) }
```

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

```JSON
{ "keysOf" : ["a","b"] }
```

### [](#例-2)例

次の例は、​`keysOf`​ と ​`namesOf`​ の違いを示しています。 `keysOf`​ は XML 入力からの属性 (​`name`​ と ​`lastName`​) と名前空間 (​`xmlns`​) を保持していますが、​`namesOf`​ はそれらを保持しないため、​`null`​ を返しています。

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

```DataWeave
%dw 2.0
var myVar = read('<users xmlns="http://test.com">
                     <user name="Mariano" lastName="Achaval"/>
                     <user name="Stacey" lastName="Duke"/>
                  </users>', 'application/xml')
output application/json
---
{ keysOfExample: flatten([keysOf(myVar.users) map $.#,
                          keysOf(myVar.users) map $.@])
}
++
{ namesOfExample: flatten([namesOf(myVar.users) map $.#,
                    namesOf(myVar.users) map $.@])
}
```

#### [](#出力-2)出力

```JSON
{
  "keysOfExample": [
    "http://test.com",
    "http://test.com",
    {
      "name": "Mariano",
      "lastName": "Achaval"
    },
    {
      "name": "Stacey",
      "lastName": "Duke"
    }
  ],
  "namesOfExample": [
    null,
    null,
    null,
    null
  ]
}
```