Skip to content

Did some language clean up / clarification on JSON.MERGE documentaiton page. #1065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Did some language clean up / clarification.
  • Loading branch information
Simon Prickett authored Aug 1, 2023
commit fbb54ac46b863a691f2d33657d54d187c9449fc9
18 changes: 9 additions & 9 deletions docs/commands/json.merge.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
Merge a given JSON value into matching paths. Consequently, JSON values at matching paths are updated, deleted, or expanded with new children.

This command complies with [RFC7396](https://datatracker.ietf.org/doc/html/rfc7396) Json Merge Patch
This command complies with [RFC7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON Merge Patch

[Examples](#examples)

## Required arguments

<details open><summary><code>key</code></summary>

is key to merge into.
is the key to merge into.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what Nermina called "telegraphic writing style". She introduced this style in all module commands that she touched.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange as it makes it sound like broken English also something being "key" in this sense means important. "is key to our understanding etc." Let's run without the "the" but this style is detrimental IMHO.

</details>

<details open><summary><code>path</code></summary>

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`.
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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the "the"


</details>

<details open><summary><code>value</code></summary>

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:
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

* merging an existing object key with a `null` value deletes the key
* merging an existing object key with non-null value updates the value
* merging a non-existing object key adds the key and value
* merging an existing array with any merged value, replaces the entire array with the value
* merging a nonexistent object key adds the key and value
* merging an existing array with any merged value replaces the entire array with the value
</details>

## Return value

JSET.MERGE returns a simple string reply: `OK` if executed correctly or `error` if fails to set the new values
JSET.MERGE returns a simple string reply: `OK` if executed correctly or `error` if fails to set the new values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON.MERGE ;-)


For more information about replies, see [Redis serialization protocol specification](/docs/reference/protocol-spec).

## Examples

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
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.

<details open>
<summary><b>Create a unexistent path-value</b></summary>
<summary><b>Create a new path-value</b></summary>

{{< highlight bash >}}
redis> JSON.SET doc $ '{"a":2}'
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy