set

Set a value at a given path.

This method chains a set operation to the patch.

The operation creates a new value at the specified path, overwriting any existing value.

Signature

This method has the following signature:

patch.set(path: string, value: JsonValue): Patch

The return is the Patch instance itself to allow operation chaining.

Example

Here is a basic example of how to use this method:

path.set('address.city', 'New York');

Parameters

The following list describes the supported parameters:

path
string

The path to the value to set in dot notation, like address.city.

value
JSON

The value to set at the specified path, like New York.