JSON.GET - Amazon ElastiCache (sistema operativo Redis)

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

Restituisce il JSON serializzato in uno o più percorsi.

Sintassi

JSON.GET <key> [INDENT indentation-string] [NEWLINE newline-string] [SPACE space-string] [NOESCAPE] [path ...]
  • key (obbligatorio) — Una chiave Redis OSS di tipo documento JSON.

  • INDENT/NEWLINE/SPACE (facoltativo) — Controlla il formato della stringa JSON restituita, cioè , “pretty print”. Il valore predefinito di ciascuno è una stringa vuota. Può essere sovrascritto in qualunque combinazione. Possono essere specificati in qualunque ordine.

  • NOESCAPE — Facoltativo, presenza consentita per compatibilità legacy senza altri effetti.

  • path (facoltativo) — Zero o più percorsi JSON; il valore predefinito è la radice, se non viene fornito. 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 un array di valori.

  • Se non è selezionato alcun valore, il comando restituisce un array vuoto.

Se vengono forniti più percorsi:

  • Restituisce un oggetto JSON con stringify, 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.

Examples (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}"