Skip to main content
Retrieves the JSON value stored at the specified key and optionally formats the output.

Usage

Arguments

key
string
required
The key containing the JSON document
opts
object
Optional formatting options for the returned JSON string
path
string | string[]
JSONPath expression(s) to specify which parts of the JSON to retrieve. If not specified, returns the entire JSON document.

Response

result
TData | null
The JSON value at the specified path, or null if the key doesn’t exist. The return type is generic and can be specified using TypeScript.

Examples

Get entire JSON document

Get specific path

Get with formatting options

Get multiple paths

JSONPath Syntax

Upstash Redis supports JSONPath expressions for querying JSON documents:
  • $ - Root element
  • $.field - Access a field
  • $.field[0] - Access array element
  • $..field - Recursive descent
  • $.field[*] - All array elements

See Also