From d703abec556cf6719ca16ffb79ce432b47a95bd8 Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 19 Dec 2023 17:22:23 +0800 Subject: [PATCH 1/2] Fix execution examples in JSON MSET doc In fact, executing the example directly will return this error: ``` redis> flushall OK redis> JSON.MSET doc1 $ '{"a":2}' doc2 $.f.a '3' doc3 $ '{"f1": {"a":1}, "f2":{"a":2}}' (error) ERR new objects must be created at the root ``` Add some JSON.SET in front of the example to avoid error and fix the incorrect responses. --- docs/commands/json.mset.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/commands/json.mset.md b/docs/commands/json.mset.md index 9584e4bcb..23532d6eb 100644 --- a/docs/commands/json.mset.md +++ b/docs/commands/json.mset.md @@ -37,14 +37,20 @@ For more information about replies, see [Redis serialization protocol specificat Add a new values in multiple keys {{< highlight bash >}} +redis> JSON.SET doc1 $ '{"a":1}' +OK +redis> JSON.SET doc2 $ '{"f":{"a":2}}' +OK +redis> JSON.SET doc3 $ '{"f1": {"a":0}, "f2":{"a":0}}' +OK redis> JSON.MSET doc1 $ '{"a":2}' doc2 $.f.a '3' doc3 $ '{"f1": {"a":1}, "f2":{"a":2}}' OK redis> JSON.GET doc1 $ "[{\"a\":2}]" redis> JSON.GET doc2 $ -"[{\"f\":{\"a\":3]" +"[{\"f\":{\"a\":3}}]" redis> JSON.GET doc3 -"{\"f1\":{\"a\":3},\"f2\":{\"a\":3}}" +"{\"f1\":{\"a\":1},\"f2\":{\"a\":2}}" {{< / highlight >}} From aa086e7170262a359c03cc74fc0e0e5b1139677e Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 19 Dec 2023 19:25:22 +0800 Subject: [PATCH 2/2] Combine the three JSON.SET commands into a single JSON.MSET command --- docs/commands/json.mset.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/commands/json.mset.md b/docs/commands/json.mset.md index 23532d6eb..c8ee61775 100644 --- a/docs/commands/json.mset.md +++ b/docs/commands/json.mset.md @@ -37,13 +37,9 @@ For more information about replies, see [Redis serialization protocol specificat Add a new values in multiple keys {{< highlight bash >}} -redis> JSON.SET doc1 $ '{"a":1}' +redis> JSON.MSET doc1 $ '{"a":1}' doc2 $ '{"f":{"a":2}}' doc3 $ '{"f1":{"a":0},"f2":{"a":0}}' OK -redis> JSON.SET doc2 $ '{"f":{"a":2}}' -OK -redis> JSON.SET doc3 $ '{"f1": {"a":0}, "f2":{"a":0}}' -OK -redis> JSON.MSET doc1 $ '{"a":2}' doc2 $.f.a '3' doc3 $ '{"f1": {"a":1}, "f2":{"a":2}}' +redis> JSON.MSET doc1 $ '{"a":2}' doc2 $.f.a '3' doc3 $ '{"f1":{"a":1},"f2":{"a":2}}' OK redis> JSON.GET doc1 $ "[{\"a\":2}]"