Usage
Arguments
The key to store the JSON document
JSONPath expression specifying where to set the value in the JSON document. Use
$ to set the entire document.The JSON value to set. Can be a number, string, boolean, object, or array.
Optional conditional set options
Response
Returns
"OK" if the value was set successfully, or null if the condition (NX/XX) was not met.Examples
Set entire JSON document
Set specific field
Set nested value
Set array element
Conditional set - only if path doesn’t exist (NX)
Conditional set - only if path exists (XX)
JSONPath Syntax
$- Root element (sets entire document)$.field- Set a specific field$.field[0]- Set array element at index$.nested.field- Set nested field
See Also
- JSON.GET - Get JSON values
- JSON.DEL - Delete JSON values
- Redis JSON.SET documentation