%dw 2.0
output application/json
---
{ "a" : [0, 1, 1, 2] -- [1,2] }
DataWeave
--
DataWeave 2.2 is compatible and bundled with Mule 4.2.
This version of Mule reached its
End of Life Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted. MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements. |
--(Array<S>, Array<Any>): Array<S>
Removes specified values from an input value.
This version of --
removes all instances of the specified items from an array. Other
versions act on objects, strings, and the various date and time formats that
are supported by DataWeave.
Name |
Description |
|
The array containing items to remove. |
|
Items to remove from the source array. |
Example
This example removes specified items from an array. Specifically, it removes
all instances of the items listed in the array on the right side of --
from
the array on the left side of the function, leaving [0]
as the result.
Source
Output
{ "a": [0] }
JSON
--({ (K)?: V }, Object): { (K)?: V }
Removes specified key-value pairs from an object.
Parameters
Name | Description |
---|---|
|
The source object (an |
|
Object that contains the key-value pairs to remove from the source object. |
Example
This example removes a key-value pair from the source object.
Source
%dw 2.0
output application/json
---
{ "hello" : "world", "name" : "DW" } -- { "hello" : "world"}
DataWeave
Output
{ "name": "DW" }
JSON
--(Object, Array<String>)
Removes all key-value pairs from the source object that match the specified search key.
Parameters
Name | Description |
---|---|
|
The source object (an |
|
An array of keys to specify the key-value pairs to remove from the source object. |
Example
This example removes two key-value pairs from the source object.
Source
%dw 2.0
output application/json
---
{ "yes" : "no", "good" : "bad", "old" : "new" } -- ["yes", "old"]
DataWeave
Output
{ "good": "bad" }
JSON
--(Object, Array<Key>)
Removes specified key-value pairs from an object.
Parameters
Name | Description |
---|---|
|
The source object (an |
|
A keys for the key-value pairs to remove from the source object. |
Example
This example specifies the key-value pair to remove from the source object.
Source
%dw 2.0
output application/json
---
{ "hello" : "world", "name" : "DW" } -- ["hello" as Key]
DataWeave
Output
{ "name": "DW" }
JSON