

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

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

Riporta informazioni. Sottocomandi supportati:
+ MEMORY <key> [path] – Riporta l’utilizzo della memoria in byte di un valore JSON. Se non è fornito, viene ripristinato il percorso predefinito, la radice.
+ FIELDS <key> [path] – Riporta il numero di campi nel percorso del documento specificato. Se non è fornito, viene ripristinato il percorso predefinito, la radice. Ogni valore JSON non container viene conteggiato come un singolo campo. Oggetti e array vengono conteggiati ricorsivamente come singolo campo per ognuno dei loro valori JSON contenenti. Ogni valore container, tranne il container radice, viene conteggiato come un campo aggiuntivo.
+ HELP – Stampa messaggi della guida del comando.

Sintassi

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

Dipende dal sottocomando:

MEMORY
+ Se il percorso è una sintassi avanzata:
  + Restituisce un array di numeri interi che rappresentano la dimensione della memoria (in byte) del valore JSON in ogni percorso.
  + Restituisce un array vuoto se la chiave Valkey o Redis OSS non esiste.
+ Se il percorso è una sintassi limitata:
  + Restituisce un numero intero, le dimensioni della memoria e il valore JSON in byte.
  + Restituisce null se la chiave Valkey o Redis OSS non esiste.

FIELDS
+ Se il percorso è una sintassi avanzata:
  + Restituisce un array di numeri interi che rappresentano il numero di campi del valore JSON in ogni percorso.
  + Restituisce un array vuoto se la chiave Valkey o Redis OSS non esiste.
+ Se il percorso è una sintassi limitata:
  + Restituisce un numero intero, il numero di campi del valore JSON.
  + Restituisce null se la chiave Valkey o Redis OSS non esiste.

HELP – Restituisce un array di messaggi della guida.

**Examples** (Esempi)

Sintassi avanzata del percorso:

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

Sintassi limitata del percorso:

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