Skip to content

Commit 0979bc7

Browse files
authored
Update json.arrinsert.md
1 parent 43656da commit 0979bc7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/commands/json.arrinsert.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ For more information about replies, see [Redis serialization protocol specificat
4343
Create a document for noise-cancelling headphones in black and silver colors.
4444

4545
{{< highlight bash >}}
46-
127.0.0.1:6379> JSON.SET item:1 $ '{"name":"Noise-cancelling Bluetooth headphones","description":"Wireless Bluetooth headphones with noise-cancelling technology","connection":{"wireless":true,"type":"Bluetooth"},"price":99.98,"stock":25,"colors":["black","silver"]}'
46+
redis> JSON.SET item:1 $ '{"name":"Noise-cancelling Bluetooth headphones","description":"Wireless Bluetooth headphones with noise-cancelling technology","connection":{"wireless":true,"type":"Bluetooth"},"price":99.98,"stock":25,"colors":["black","silver"]}'
4747
OK
4848
{{< / highlight >}}
4949

5050
Add color `blue` to the end of the `colors` array. `JSON.ARRAPEND` returns the array's new size.
5151

5252
{{< highlight bash >}}
53-
127.0.0.1:6379> JSON.ARRAPPEND item:1 $.colors '"blue"'
53+
redis> JSON.ARRAPPEND item:1 $.colors '"blue"'
5454
1) (integer) 3
5555
{{< / highlight >}}
5656

@@ -64,21 +64,21 @@ JSON.GET item:1
6464
Get the list of colors for the product.
6565

6666
{{< highlight bash >}}
67-
127.0.0.1:6379> JSON.GET item:1 '$.colors[*]'
67+
redis> JSON.GET item:1 '$.colors[*]'
6868
"[\"black\",\"silver\",\"blue\"]"
6969
{{< / highlight >}}
7070

7171
Insert two more colors after the second color. You now have five colors.
7272

7373
{{< highlight bash >}}
74-
127.0.0.1:6379> JSON.ARRINSERT item:1 $.colors 2 '"yellow"' '"gold"'
74+
redis> JSON.ARRINSERT item:1 $.colors 2 '"yellow"' '"gold"'
7575
1) (integer) 5
7676
{{< / highlight >}}
7777

7878
Get the updated list of colors.
7979

8080
{{< highlight bash >}}
81-
127.0.0.1:6379> JSON.GET item:1 $.colors
81+
redis> JSON.GET item:1 $.colors
8282
"[[\"black\",\"silver\",\"yellow\",\"gold\",\"blue\"]]"
8383
{{< / highlight >}}
8484
</details>

0 commit comments

Comments
 (0)