

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# JSON.DEBUG
<a name="json-debug"></a>

レポート情報。サポートされるサブコマンドは以下のとおりです。
+ MEMORY <key> [path] – メモリの使用状況を JSON 値のバイト数でレポートします。パスが指定されていない場合、デフォルトはルートになります。
+ DEPTH <key> [path] – JSON ドキュメントの最大パス深度を報告します。
**注記**  
このサブコマンドは、Valkey 7.2 以降または Redis OSS エンジンバージョン 6.2.6.R2 以降でのみ使用できます。
+ FIELDS <key> [path] – 指定されたドキュメントパスのフィールド数をレポートします。パスが指定されていない場合、デフォルトはルートになります。コンテナ以外の JSON 値はそれぞれ 1 つのフィールドとしてカウントされます。オブジェクトと配列は、それらを含む JSON 値ごとに 1 つのフィールドを再帰的にカウントします。ルートコンテナを除く各コンテナ値は、1 つの追加フィールドとしてカウントされます。
+ HELP – コマンドに関するヘルプメッセージを出力します。

構文

```
JSON.DEBUG <subcommand & arguments>
```

サブコマンドによって異なります。

MEMORY
+ パスが拡張構文の場合:
  + 各パスの JSON 値のフィールド数を表す整数の配列を返します。
  + キーが存在しない場合は、空の配列を返します。
+ パスが制限構文の場合:
  + 整数のメモリサイズ、および JSON 値 (バイト単位) を返します。
  + キーが存在しない場合は、null を返します。

DEPTH
+ JSON ドキュメントの最大パス深度を表す整数を返します。
+ キーが存在しない場合は、null を返します。

FIELDS
+ パスが拡張構文の場合:
  + 各パスにおける JSON 値のフィールド数を表す整数の配列を返します。
  + キーが存在しない場合は、空の配列を返します。
+ パスが制限構文の場合:
  + JSON 値のフィールド数を整数で返します。
  + キーが存在しない場合は、null を返します。

HELP - ヘルプメッセージの配列を返します。

**例**

拡張パス構文:

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