---
schema_version: "1"
id: a74ce641159408e854ed3a60203cfbbe40ad46b9dbaab189c653b2a15250b9a7
title: mergeWith
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-objects-functions-mergewith.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-objects-functions-mergewith
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 72c91b4ddcf6725f8f4ea581b923299afd7d40b8b5cf317f91614d700be06512
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# mergeWith

## [](#mergewith1)mergeWith<T <: Object, V <: Object>(source: T, target: V): ?

取得元オブジェクトからのすべてのキー - 値ペアを対象オブジェクトに追加します。

取得元オブジェクトと対象オブジェクトに同じキーがあれば、この関数は、その取得元オブジェクトを対象に追加し、その対象オブジェクトを出力から削除します。

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

<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>source</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>target</code>​ に追加するオブジェクト。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>target</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>source</code>​ が追加されるオブジェクト。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、取得元オブジェクトを対象に追加します。​`"a" : true,`​ は出力から削除され、​`"a" : false`​ が対象に追加されています。

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

```DataWeave
%dw 2.0
import mergeWith from dw::core::Objects
output application/json
---
{ "mergeWith" : { "a" : true, "b" : 1} mergeWith { "a" : false, "c" : "Test"} }
```

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

```JSON
"mergeWith": {
    "b": 1,
    "a": false,
    "c": "Test"
}
```

## [](#mergewith2)mergeWith<T <: Object>(a: Null, b: T): T

`mergeWith`​ を ​`null`​ 値に使用できるようにするヘルパー関数。

## [](#mergewith3)mergeWith<T <: Object>(a: T, b: Null): T

`mergeWith`​ を ​`null`​ 値に使用できるようにするヘルパー関数。