|
1 | 1 | Merge a given JSON value into matching paths. Consequently, JSON values at matching paths are updated, deleted, or expanded with new children.
|
2 | 2 |
|
3 |
| -This command complies with [RFC7396](https://datatracker.ietf.org/doc/html/rfc7396) Json Merge Patch |
| 3 | +This command complies with [RFC7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON Merge Patch |
4 | 4 |
|
5 | 5 | [Examples](#examples)
|
6 | 6 |
|
7 | 7 | ## Required arguments
|
8 | 8 |
|
9 | 9 | <details open><summary><code>key</code></summary>
|
10 | 10 |
|
11 |
| -is key to merge into. |
| 11 | +is the key to merge into. |
12 | 12 | </details>
|
13 | 13 |
|
14 | 14 | <details open><summary><code>path</code></summary>
|
15 | 15 |
|
16 |
| -is JSONPath to specify. For non-existing keys the `path` must be `$`. For existing keys, for each matched `path`, the value that matches the `path` is being merged with the JSON `value`. For existing keys, when the path exists, except for the last element, a new child is added with the JSON `value`. |
| 16 | +is the JSONPath to specify where in the JSON document to apply the merge. For non-existing keys the `path` must be `$`. For existing keys, for each matched `path`, the value that matches the `path` is merged with the JSON `value`. For existing keys, when the path exists, except for the last element, a new child is added with the JSON `value`. |
17 | 17 |
|
18 | 18 | </details>
|
19 | 19 |
|
20 | 20 | <details open><summary><code>value</code></summary>
|
21 | 21 |
|
22 |
| -is JSON value to merge with at the specified path. Merging is done according to the following rules per JSON value in the `value` argument while considering the corresponding original value if it exists: |
| 22 | +is the JSON value to merge with at the specified path. Merging is done according to the following rules per JSON value in the `value` argument while considering the corresponding original value if it exists: |
23 | 23 | * merging an existing object key with a `null` value deletes the key
|
24 | 24 | * merging an existing object key with non-null value updates the value
|
25 |
| -* merging a non-existing object key adds the key and value |
26 |
| -* merging an existing array with any merged value, replaces the entire array with the value |
| 25 | +* merging a nonexistent object key adds the key and value |
| 26 | +* merging an existing array with any merged value replaces the entire array with the value |
27 | 27 | </details>
|
28 | 28 |
|
29 | 29 | ## Return value
|
30 | 30 |
|
31 |
| -JSET.MERGE returns a simple string reply: `OK` if executed correctly or `error` if fails to set the new values |
| 31 | +JSET.MERGE returns a simple string reply: `OK` if executed correctly or `error` if fails to set the new values. |
32 | 32 |
|
33 | 33 | For more information about replies, see [Redis serialization protocol specification](/docs/reference/protocol-spec).
|
34 | 34 |
|
35 | 35 | ## Examples
|
36 | 36 |
|
37 |
| -The JSON.MERGE provide four different behaviours to merge changes on a given key: create unexistent path, update an existing path with a new value, delete a existing path or replace an array with a new array |
| 37 | +The JSON.MERGE command provides four different behaviors to merge changes on a given key: create a new path, update an existing path with a new value, delete a existing path or replace an array with a new array. |
38 | 38 |
|
39 | 39 | <details open>
|
40 |
| -<summary><b>Create a unexistent path-value</b></summary> |
| 40 | +<summary><b>Create a new path-value</b></summary> |
41 | 41 |
|
42 | 42 | {{< highlight bash >}}
|
43 | 43 | redis> JSON.SET doc $ '{"a":2}'
|
|
0 commit comments