Getting started Community Training Tutorials Documentation APIs, AI & Tools
%dw 2.0
import * from dw::util::Values
output application/json
---
{name: "Mariano"} update "name" with "Data Weave"
This update function updates a field in an object with the specified
string value.
The function returns a new object with the specified field and value.
Introduced in DataWeave version 2.2.2.
This update function updates an object field with the specified
PathElement value.
The function returns a new object with the specified field and value.
Introduced in DataWeave version 2.2.2.
| Name | Description |
|---|---|
|
The object to update. |
|
A |
This example updates the value of a name field in the object
{name: "Mariano"}. It uses field("name") to return the PathElement
that it passes to update. It uses with "Data Weave" to specify the value
(Data Weave) of name.
Updates an array index with the specified value.
This update function returns a new array that changes the value of
the specified index.
Introduced in DataWeave version 2.2.2.
This update function updates all objects within the specified array with
the given string value.
Introduced in DataWeave version 2.2.2.
| Name | Description |
|---|---|
|
The array of objects to update. |
|
A string providing the name of the field to update. |
This update function updates the specified index of an array with the
given PathElement value.
The function returns a new array that contains given value at the specified index.
Introduced in DataWeave version 2.2.2.
| Name | Description |
|---|---|
|
The array to update. |
|
The index of the array to update. The index must be specified as a |
This example updates the value of an element in the input array. Notice
that it uses index(1) to return the index as a PathElement, which
it passes to update. It replaces the value 2 at that index with 5.
Updates the value at the specified path with the given value.
Introduced in DataWeave version 2.2.2.
| Name | Description |
|---|---|
|
The value to update. Accepts an array, object, or null value. |
|
The path to update. The path must be an array of strings, numbers, or `PathElement`s. |
This example updates the name of the user.
This example updates one of the recurring fields.
<users>
<user>
<name>Phoebe</name>
<language>French</language>
</user>
<user>
<name>Joey</name>
<language>English</language>
</user>
</users>