本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
JSON.DEBUG
報告資訊。支援的子命令如下:
記憶體 <key>[路徑] — 以 JSON 值的位元組報告記憶體使用情況。如果未提供,路徑預設為根。
深度 <key>[路徑] — 報告 JSON 文件的最大路徑深度。
注意
只有使用 Redis 的 OSS 引擎版本 6.6.R2 或更新版本才能使用此子命令。
欄位 <key>[路徑] — 報告指定文件路徑上的欄位數目。如果未提供,路徑預設為根。每個非容器 JSON 值都計為一個欄位。物件和陣列遞迴計為每個內含 JSON 值的一個欄位。除根容器外,每個容器值都計為一個附加欄位。
幫助-打印命令的幫助消息。
語法
JSON.DEBUG <subcommand & arguments>
取決於子命令:
MEMORY
如果路徑是增強型語法:
返回一個整數數組,代表每個路徑中 JSON 值的內存大小(以字節為單位)。
如果 Redis 的 OSS 鍵不存在,則返回一個空數組。
如果路徑是受限語法:
返回一個整數,內存大小以字節為單位的 JSON 值。
如果 Redis 的 OSS 鍵不存在,則返回 null。
DEPTH
傳回整數,代表 JSON 文件的最大路徑深度。
如果 Redis 的 OSS 金鑰不存在,則傳回 null。
FIELDS
如果路徑是增強型語法:
返回一個整數數組,代表在每個路徑 JSON 值的字段數。
如果 Redis 的 OSS 鍵不存在,則返回一個空數組。
如果路徑是受限語法:
返回一個整數,JSON 值的字段數。
如果 Redis 的 OSS 鍵不存在,則返回 null。
幫助-返回幫助消息的數組。
範例
增強型路徑語法:
127.0.0.1:6379> JSON.SET k1 . '[1, 2.3, "foo", true, null, {}, [], {"a":1, "b":2}, [1,2,3]]' OK 127.0.0.1:6379> JSON.DEBUG MEMORY k1 $[*] 1) (integer) 16 2) (integer) 16 3) (integer) 19 4) (integer) 16 5) (integer) 16 6) (integer) 16 7) (integer) 16 8) (integer) 50 9) (integer) 64 127.0.0.1:6379> JSON.DEBUG FIELDS k1 $[*] 1) (integer) 1 2) (integer) 1 3) (integer) 1 4) (integer) 1 5) (integer) 1 6) (integer) 0 7) (integer) 0 8) (integer) 2 9) (integer) 3
受限路徑語法:
127.0.0.1:6379> JSON.SET k1 . '{"firstName":"John","lastName":"Smith","age":27,"weight":135.25,"isAlive":true,"address":{"street":"21 2nd Street","city":"New York","state":"NY","zipcode":"10021-3100"},"phoneNumbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}],"children":[],"spouse":null}' OK 127.0.0.1:6379> JSON.DEBUG MEMORY k1 (integer) 632 127.0.0.1:6379> JSON.DEBUG MEMORY k1 .phoneNumbers (integer) 166 127.0.0.1:6379> JSON.DEBUG FIELDS k1 (integer) 19 127.0.0.1:6379> JSON.DEBUG FIELDS k1 .address (integer) 4 127.0.0.1:6379> JSON.DEBUG HELP 1) JSON.DEBUG MEMORY <key> [path] - report memory size (bytes) of the JSON element. Path defaults to root if not provided. 2) JSON.DEBUG FIELDS <key> [path] - report number of fields in the JSON element. Path defaults to root if not provided. 3) JSON.DEBUG HELP - print help message.