JSON.RESP

Syntax

  1. JSON.RESP key [path]

Time complexity: O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key

ACL categories: @json

Return the JSON in key in Redis serialization protocol specification form

Examples

Required arguments

key

is key to parse.

Optional arguments

path

is JSONPath to specify. Default is root $. This command uses the following mapping from JSON to RESP:

  • JSON null maps to the bulk string reply.
  • JSON false and true values map to the simple string reply.
  • JSON number maps to the integer reply or bulk string reply, depending on type.
  • JSON string maps to the bulk string reply.
  • JSON array is represented as an array reply in which the first element is the simple string reply [, followed by the array’s elements.
  • JSON object is represented as an array reply in which the first element is the simple string reply {. Each successive entry represents a key-value pair as a two-entry array reply of the bulk string reply.

For more information about replies, see Redis serialization protocol specification.

Return

JSON.RESP returns an array reply specified as the JSON’s RESP form detailed in Redis serialization protocol specification.

Examples

Return an array of RESP details about a document

Create a JSON document.

  1. dragonfly> JSON.SET item:2 $ '{"name":"Wireless earbuds","description":"Wireless Bluetooth in-ear headphones","connection":{"wireless":true,"type":"Bluetooth"},"price":64.99,"stock":17,"colors":["black","white"], "max_level":[80, 100, 120]}'
  2. OK

Get all RESP details about the document.

  1. dragonfly> JSON.RESP item:2
  2. 1) {
  3. 2) "name"
  4. 3) "Wireless earbuds"
  5. 4) "description"
  6. 5) "Wireless Bluetooth in-ear headphones"
  7. 6) "connection"
  8. 7) 1) {
  9. 2) "wireless"
  10. 3) true
  11. 4) "type"
  12. 5) "Bluetooth"
  13. 8) "price"
  14. 9) "64.989999999999995"
  15. 10) "stock"
  16. 11) (integer) 17
  17. 12) "colors"
  18. 13) 1) [
  19. 2) "black"
  20. 3) "white"
  21. 14) "max_level"
  22. 15) 1) [
  23. 2) (integer) 80
  24. 3) (integer) 100
  25. 4) (integer) 120

See also

JSON.SET | JSON.ARRLEN