

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.RESP
<a name="json-resp"></a>

Restituisce il valore JSON nel percorso specificato nel Valkey o Redis OSS Serialization Protocol (RESP). Se il valore è container, la risposta è un array RESP o un array annidato.
+ Un valore null JSON è mappato alla stringa in blocco null RESP.
+ I valori booleani JSON vengono mappati alle rispettive stringhe semplici RESP.
+ I numeri interi sono mappati a numeri interi RESP.
+ I numeri a virgola mobile doppia IEEE a 64 bit sono mappati a stringhe in blocco RESP.
+ Le stringhe JSON sono mappate su RESP Bulk Strings.
+ Gli array JSON sono rappresentati come array RESP, dove il primo elemento è la semplice stringa [, seguita dagli elementi dell'array.
+ Gli oggetti JSON sono rappresentati come array RESP, dove il primo elemento è la semplice stringa \$1, seguita da coppie chiave-valore, ognuna delle quali è una stringa di massa RESP.

Sintassi

```
JSON.RESP <key> [path]
```
+ key (obbligatorio) — chiave del tipo di documento JSON
+ path (opzionale) — un percorso JSON. Il valore predefinito è root se non viene fornito

**Valori restituiti**

Se il percorso è una sintassi avanzata:
+ Array di array. Ogni elemento dell'array rappresenta la forma RESP del valore in un unico percorso.
+ Array vuoto se la chiave del documento non esiste.

Se il percorso è una sintassi limitata:
+ Array, che rappresenta la forma RESP del valore nel percorso.
+ Null se la chiave del documento non esiste.

**Esempi**

Sintassi avanzata 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.RESP k1 $.address
1) 1) {
   2) 1) "street"
      2) "21 2nd Street"
   3) 1) "city"
      2) "New York"
   4) 1) "state"
      2) "NY"
   5) 1) "zipcode"
      2) "10021-3100"

127.0.0.1:6379> JSON.RESP k1 $.address.*
1) "21 2nd Street"
2) "New York"
3) "NY"
4) "10021-3100"

127.0.0.1:6379> JSON.RESP k1 $.phoneNumbers
1) 1) [
   2) 1) {
      2) 1) "type"
         2) "home"
      3) 1) "number"
         2) "555 555-1234"
   3) 1) {
      2) 1) "type"
         2) "office"
      3) 1) "number"
         2) "555 555-4567"

127.0.0.1:6379> JSON.RESP k1 $.phoneNumbers[*]
1) 1) {
   2) 1) "type"
      2) "home"
   3) 1) "number"
      2) "212 555-1234"
2) 1) {
   2) 1) "type"
      2) "office"
   3) 1) "number"
      2) "555 555-4567"
```

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.RESP k1 .address
1) {
2) 1) "street"
   2) "21 2nd Street"
3) 1) "city"
   2) "New York"
4) 1) "state"
   2) "NY"
5) 1) "zipcode"
   2) "10021-3100"

127.0.0.1:6379> JSON.RESP k1
 1) {
 2) 1) "firstName"
    2) "John"
 3) 1) "lastName"
    2) "Smith"
 4) 1) "age"
    2) (integer) 27
 5) 1) "weight"
    2) "135.25"
 6) 1) "isAlive"
    2) true
 7) 1) "address"
    2) 1) {
       2) 1) "street"
          2) "21 2nd Street"
       3) 1) "city"
          2) "New York"
       4) 1) "state"
          2) "NY"
       5) 1) "zipcode"
          2) "10021-3100"
 8) 1) "phoneNumbers"
    2) 1) [
       2) 1) {
          2) 1) "type"
             2) "home"
          3) 1) "number"
             2) "212 555-1234"
       3) 1) {
          2) 1) "type"
             2) "office"
          3) 1) "number"
             2) "555 555-4567"
 9) 1) "children"
    2) 1) [
10) 1) "spouse"
    2) (nil)
```