JSON.SET

Since 1.1.0JSON

Syntax

JSON.SET key path value [NX | XX] [FPHA FP16 | BF16 | FP32 | FP64]
  • Flags: write
  • ACL categories: @json, @slow, @write
  • Arity: -2

Sets the value at path in the JSON document at key to value, which is JSON text. A JSONPath sets every value it matches. If the path matches nothing but ends in a member name under one existing object, that member is added. A new key must be created at the root, $.

See JSON paths for how paths work.

Options

OptionEffect
NXSet only if the path matches nothing.
XXSet only if the path matches something.
FPHA FP16 | BF16 | FP32 | FP64The floating-point type arrays of floats in value are stored as (Redis 8.8).

Reply

  • OK.
  • nil if NX or XX was not met, or nothing was set.
  • ERR new objects must be created at the root for a new key and a path other than $.

Examples

> JSON.SET d $ '{"name":"Ada","age":36}'
OK
> JSON.SET d $.age 37
OK
> JSON.SET d $.email '"ada@x"'
OK
> JSON.SET d $.age 1 NX
(nil)
> JSON.SET new $.a 1
(error) ERR new objects must be created at the root