Update JSON
Use this step to override a part of a JSON value from a variable with a new value and store the result in a variable.
In most cases, to update a JSON value, you can simply use the Assign step. But in more complicated cases, such as when you have a large JSON value and you need to update it, you may need to add a Find JSON Object step first to find something in this JSON value and return the path to it. Thus, to update this JSON value using a path, you must add an Update JSON step. The difference between these two approaches is that with the Assign step, you can add a new key by adding it to the path, for example, a[0].b, where a[0] contains a JSON object without the key b. However, it is not possible to do the same with Update JSON, because this step assumes that the path already exists. If the path does not exist, the step throws an error.
Properties
- Variable To Update
-
The input JSON value.
- Path
-
A JSON path to the value that requires an update. It should be represented as a text or a JSON text value.
- New Value
-
The new value to assign to the specified path.
The $value built-in variable contains the original value at the place where you want to update and may be used to create a new value.
Update JSON example
This example demonstrates a scenario where you need to update a JSON value of the key "a" in the first object of an array by adding 1 to its current value.
First, we assign a JSON value to a variable by adding an Assign step. Next, an Update JSON step is configured to update the required variable.
