---
schema_version: "1"
id: 3c637c61cf58564753ae182c8ae93d7db4ea0a7835dada7353e7b15dfd1ca3fe
title: mergeWith
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-objects-functions-mergewith.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-objects-functions-mergewith
source_site: docs.mulesoft.com
content_type: documentation
content_hash: df7b5d93a017884a5d0b1d2ac48165dc9fb553fd9ad54dd3c159dfbdeb12ab2d
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# mergeWith

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## mergeWith(T, V): ?

Appends any key-value pairs from a source object to a target object.

If source and target objects have the same key, the function appends that source object to the
target and removes that target object from the output.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>source</code></p></td><td><p>The object to append to the <code>target</code>.</p></td></tr><tr><td><p><code>target</code></p></td><td><p>The object to which the <code>source</code> object is appended.</p></td></tr></tbody></table>

### Example

This example appends the source objects to the target. Notice that `"a" : true,` is removed from the
output, and `"a" : false` is appended to the target.

#### Source

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

#### Output

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

## mergeWith(Null, T): T

Helper function that enables `mergeWith` to work with a `null` value.

## mergeWith(T, Null): T

Helper function that enables `mergeWith` to work with a `null` value.
