

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.GET
<a name="json-get"></a>

Restituisce il codice JSON serializzato su uno o più percorsi.

Sintassi

```
JSON.GET <key>
[INDENT indentation-string]
[NEWLINE newline-string]
[SPACE space-string]
[NOESCAPE]
[path ...]
```
+ key (obbligatorio): chiave del tipo di documento JSON
+ INDENT/NEWLINE/SPACE(opzionale) — controlla il formato della stringa JSON restituita, ad esempio «pretty print». Il valore predefinito di ognuno è una stringa vuota. Possono essere sostituiti in qualsiasi combinazione. Possono essere specificati in qualunque ordine.
+ NOESCAPE: opzionale, può essere presente per motivi di compatibilità con le versioni precedenti e non ha altri effetti.
+ path (opzionale): zero o più percorsi JSON, il valore predefinito è root se non ne viene fornito nessuno. Gli argomenti del percorso devono essere collocati alla fine.

**Valori restituiti**

Sintassi avanzata del percorso:

 Se viene fornito un percorso:
+ Restituisce una stringa serializzata di una matrice di valori.
+ Se non è selezionato alcun valore, il comando restituisce un array vuoto.

 Se vengono forniti più percorsi:
+ Restituisce un oggetto JSON con stringhe, in cui ogni percorso è una chiave.
+ in presenza di sintassi mista e avanzata dei percorsi, il risultato è conforme alla sintassi avanzata.
+ Se un percorso non esiste, il valore corrispondente è un array vuoto.

**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.GET k1 $.address.*
"[\"21 2nd Street\",\"New York\",\"NY\",\"10021-3100\"]"
127.0.0.1:6379> JSON.GET k1 indent "\t" space " " NEWLINE "\n" $.address.*
"[\n\t\"21 2nd Street\",\n\t\"New York\",\n\t\"NY\",\n\t\"10021-3100\"\n]"
127.0.0.1:6379> JSON.GET k1 $.firstName $.lastName $.age
"{\"$.firstName\":[\"John\"],\"$.lastName\":[\"Smith\"],\"$.age\":[27]}"            
127.0.0.1:6379> JSON.SET k2 . '{"a":{}, "b":{"a":1}, "c":{"a":1, "b":2}}'
OK
127.0.0.1:6379> json.get k2 $..*
"[{},{\"a\":1},{\"a\":1,\"b\":2},1,1,2]"
```

 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.GET k1 .address
"{\"street\":\"21 2nd Street\",\"city\":\"New York\",\"state\":\"NY\",\"zipcode\":\"10021-3100\"}"
127.0.0.1:6379> JSON.GET k1 indent "\t" space " " NEWLINE "\n" .address
"{\n\t\"street\": \"21 2nd Street\",\n\t\"city\": \"New York\",\n\t\"state\": \"NY\",\n\t\"zipcode\": \"10021-3100\"\n}"
127.0.0.1:6379> JSON.GET k1 .firstName .lastName .age
"{\".firstName\":\"John\",\".lastName\":\"Smith\",\".age\":27}"
```