You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/src/content/docs/commands/JSON.DEBUG.md
+41-39Lines changed: 41 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -5,88 +5,90 @@ description: Documentation for the DiceDB command JSON.DEBUG
5
5
6
6
The `JSON.DEBUG` command in DiceDB is part of the DiceDBJSON module, which allows for the manipulation and querying of JSON data stored in DiceDB. This command is primarily used for debugging purposes, providing insights into the internal representation of JSON data within DiceDB.
7
7
8
-
## Parameters
9
-
10
-
### Syntax
8
+
## Syntax
11
9
12
10
```bash
13
11
JSON.DEBUG <subcommand><key> [path]
14
12
```
15
13
16
-
###Parameters Description
14
+
## Parameters
17
15
18
-
-`subcommand`: (Required) The specific debug operation to perform. Currently, the supported subcommand is `MEMORY`.
19
-
-`key`: (Required) The key under which the JSON data is stored.
20
-
-`path`: (Optional) The JSON path to the specific part of the JSON data to debug. Defaults to the root if not provided.
| if `MEMORY` subcommand is used | Memory usage in bytes of the JSON value at the specified path.|
31
31
32
32
## Behaviour
33
33
34
-
When the `JSON.DEBUG` command is executed, DiceDB will perform the specified debug operation on the JSON data stored at the given key and path. For the `MEMORY` subcommand, it will calculate and return the memory usage of the JSON value at the specified path. If the path is not provided, it defaults to the root of the JSON data.
34
+
- For the `MEMORY` subcommand, it will calculate and return the memory usage of the JSON value at the specified path.
35
+
- If the path is not provided, it defaults to the root of the JSON data.
35
36
36
37
## Errors
37
38
38
-
The `JSON.DEBUG` command can raise errors in the following scenarios:
39
-
40
-
1.`Invalid Subcommand`: If an unsupported subcommand is provided, DiceDB will return an error.
- Occurs when an unsupported subcommand is provided.
42
+
43
+
2.`Invalid Path`:
44
+
- Error Message: `ERR Path '<path>' does not exist`
45
+
- If the specified path does not exist within the JSON data, DiceDB will return an error.
49
46
50
-
-`Error Message`: `ERR path '<path>' does not exist`
51
-
52
-
4.`Wrong Type`: If the key exists but does not hold JSON data, DiceDB will return an error.
53
-
54
-
-`Error Message`: `WRONGTYPE Operation against a key holding the wrong kind of value`
47
+
4.`Wrong Type`:
48
+
- Error Message: `WRONGTYPE Operation against a key holding the wrong kind of value`
49
+
- If the key exists but does not hold JSON data, DiceDB will return an error.
55
50
56
51
## Example Usage
57
52
58
53
### Debugging Memory Usage of Entire JSON Data
59
54
55
+
The `JSON.DEBUG MEMORY` command is used to get the memory usage of the entire JSON data stored under the key `myjson`. The command returns `89`, indicating that the JSON data occupies 89 bytes of memory.
56
+
60
57
```bash
58
+
127.0.0.1:7379> JSON.SET myjson $ '{"a":1}',
59
+
OK
61
60
127.0.0.1:7379> JSON.DEBUG MEMORY myjson
62
-
(integer) 256
61
+
(integer) 89
63
62
```
64
63
65
-
In this example, the `JSON.DEBUG MEMORY` command is used to get the memory usage of the entire JSON data stored under the key `myjson`. The command returns `256`, indicating that the JSON data occupies 256 bytes of memory.
66
-
67
64
### Debugging Memory Usage of a Specific Path
68
65
66
+
The `JSON.DEBUG MEMORY` command is used to get the memory usage of the JSON value at the path `$.a` within the JSON data stored under the key `myjson`. The command returns `16`, indicating that the specified JSON value occupies 16 bytes of memory.
In this example, the `JSON.DEBUG MEMORY` command is used to get the memory usage of the JSON value at the path `$.store.book[0]` within the JSON data stored under the key `myjson`. The command returns `64`, indicating that the specified JSON value occupies 64 bytes of memory.
75
-
76
74
### Handling Non-Existent Key
77
75
76
+
The `JSON.DEBUG MEMORY` command is used on a non-existent key `nonExistentKey`. DiceDB returns an 0 indicating that the key does not exist.
77
+
78
78
```bash
79
79
127.0.0.1:7379> JSON.DEBUG MEMORY nonExistentKey
80
-
(error) ERR no such key
80
+
(integer) 0
81
81
```
82
82
83
-
In this example, the `JSON.DEBUG MEMORY` command is used on a non-existent key `nonExistentKey`. DiceDB returns an error indicating that the key does not exist.
84
-
85
83
### Handling Invalid Path
86
84
85
+
The `JSON.DEBUG MEMORY` command is used on an invalid path `$.nonExistentPath` within the JSON data stored under the key `myjson`. DiceDB returns an error indicating that the specified path does not exist.
(error) ERR path'$.nonExistentPath' does not exist
89
+
(error) ERR Path'$.nonExistentPath' does not exist
90
90
```
91
91
92
-
In this example, the `JSON.DEBUG MEMORY` command is used on an invalid path `$.nonExistentPath` within the JSON data stored under the key `myjson`. DiceDB returns an error indicating that the specified path does not exist.
92
+
## Notes
93
+
94
+
- JSONPath expressions are used to navigate and specify the location within the JSON document. Familiarity with JSONPath syntax is beneficial for effective use of this command.
description: Documentation for the DiceDB command JSON.RESP
4
+
---
5
+
6
+
The `JSON.RESP` command in DiceDB is part of the DiceDBJSON module, which returns the JSON in the specified key in Redis Serialization Protocol Specification (RESP) form.
- JSONPath expressions are used to navigate and specify the location within the JSON document. Familiarity with JSONPath syntax is beneficial for effective use of this command.
0 commit comments