{
  "schema_version": 2,
  "id": "develop/data-types/json",
  "title": "JSON",
  "url": "https://redis.io/docs/latest/develop/data-types/json/",
  "summary": "JSON support for Redis",
  "aliases": [
    "/data-types/json/",
    "/manual/data-types/json/",
    "/stack/json/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-30T13:16:11-07:00",
  "children": [
    {
      "id": "develop/data-types/json/indexing_JSON",
      "summary": "Combine Redis JSON and Redis Search to index and search JSON documents",
      "title": "Index/Search JSON documents",
      "url": "https://redis.io/docs/latest/develop/data-types/json/indexing_json/"
    },
    {
      "id": "develop/data-types/json/path",
      "summary": "Access specific elements within a JSON document",
      "title": "Path",
      "url": "https://redis.io/docs/latest/develop/data-types/json/path/"
    },
    {
      "id": "develop/data-types/json/use_cases",
      "summary": "JSON use cases",
      "title": "Use cases",
      "url": "https://redis.io/docs/latest/develop/data-types/json/use_cases/"
    },
    {
      "id": "develop/data-types/json/performance",
      "summary": "Performance benchmarks",
      "title": "Performance",
      "url": "https://redis.io/docs/latest/develop/data-types/json/performance/"
    },
    {
      "id": "develop/data-types/json/ram",
      "summary": "Debugging memory consumption",
      "title": "Redis JSON RAM Usage",
      "url": "https://redis.io/docs/latest/develop/data-types/json/ram/"
    },
    {
      "id": "develop/data-types/json/resp3",
      "summary": "JSON RESP2 to RESP3 replies reference for client developers",
      "title": "Guide for migrating from RESP2 to RESP3 replies",
      "url": "https://redis.io/docs/latest/develop/data-types/json/resp3/"
    },
    {
      "id": "develop/data-types/json/developer",
      "summary": "Notes on JSON debugging, testing and documentation.",
      "title": "Developer notes",
      "url": "https://redis.io/docs/latest/develop/data-types/json/developer/"
    }
  ],
  "page_type": "content",
  "content_hash": "7678974010d7385c4c9d03d5f4e64214325a499e8043156c5ecdb0c348c50c0e",
  "sections": [
    {
      "id": "json-command-summary",
      "title": "JSON command summary",
      "role": "content",
      "text": "**25 commands in this group:**\n\n[View all json commands](https://redis.io/commands/?group=json)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [JSON.ARRAPPEND](https://redis.io/commands/json.arrappend/) | Append the JSON values into the array at path after the last element in it | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.ARRINDEX](https://redis.io/commands/json.arrindex/) | Search for the first occurrence of a JSON value in an array | O(N) when path is evaluated to a single value w... | 1.0.0 |\n| [JSON.ARRINSERT](https://redis.io/commands/json.arrinsert/) | Insert the json values into the array at path before the index (shifts to the right) | O(N) when path is evaluated to a single value w... | 1.0.0 |\n| [JSON.ARRLEN](https://redis.io/commands/json.arrlen/) | Report the length of the JSON array at path in key | O(1) where path is evaluated to a single value,... | 1.0.0 |\n| [JSON.ARRPOP](https://redis.io/commands/json.arrpop/) | Remove and return the element at the specified index in the array at path | O(N) when path is evaluated to a single value w... | 1.0.0 |\n| [JSON.ARRTRIM](https://redis.io/commands/json.arrtrim/) | Trim an array so that it contains only the specified inclusive range of elements | O(N) when path is evaluated to a single value w... | 1.0.0 |\n| [JSON.CLEAR](https://redis.io/commands/json.clear/) | Clear container values (arrays/objects) and set numeric values to 0 | O(N) when path is evaluated to a single value w... | 2.0.0 |\n| [JSON.DEBUG](https://redis.io/commands/json.debug/) | This is a container command for debugging related tasks | N/A | 1.0.0 |\n| [JSON.DEL](https://redis.io/commands/json.del/) | Delete a value | O(N) when path is evaluated to a single value w... | 1.0.0 |\n| [JSON.FORGET](https://redis.io/commands/json.forget/) | Delete a value | O(N) when path is evaluated to a single value w... | 1.0.0 |\n\n#### JSON command summary (part 2)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [JSON.GET](https://redis.io/commands/json.get/) | Get JSON value at path | O(N) where N is the size of the JSON | 1.0.0 |\n| [JSON.MERGE](https://redis.io/commands/json.merge/) | Merge a given JSON value into matching paths. Consequently, JSON values at matching paths are updated, deleted, or expanded with new children | O(M+N) when path is evaluated to a single value... | 2.6.0 |\n| [JSON.MGET](https://redis.io/commands/json.mget/) | Return the values at path from multiple key arguments | O(M*N) when path is evaluated to a single value... | 1.0.0 |\n| [JSON.MSET](https://redis.io/commands/json.mset/) | Set or update one or more JSON values according to the specified key-path-value triplets | O(K*(M+N)) where k is the number of keys in the... | 2.6.0 |\n| [JSON.NUMINCRBY](https://redis.io/commands/json.numincrby/) | Increment the number value stored at path by number | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.NUMMULTBY](https://redis.io/commands/json.nummultby/) | Multiply the number value stored at path by number | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.NUMPOWBY](https://redis.io/commands/json.numpowby/) | Raise the number value stored at path to the power of number | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.OBJKEYS](https://redis.io/commands/json.objkeys/) | Return the keys in the object that's referenced by path | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.OBJLEN](https://redis.io/commands/json.objlen/) | Report the number of keys in the JSON object at path in key | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.RESP](https://redis.io/commands/json.resp/) | Return the JSON in key in Redis serialization protocol specification form | O(N) when path is evaluated to a single value, ... | 1.0.0 |\n\n#### JSON command summary (part 3)\n\n| Command | Summary | Complexity | Since |\n|---------|---------|------------|-------|\n| [JSON.SET](https://redis.io/commands/json.set/) | Set the JSON value at path in key | O(M+N) where M is the size of the original valu... | 1.0.0 |\n| [JSON.STRAPPEND](https://redis.io/commands/json.strappend/) | Append the json-string values to the string at path | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.STRLEN](https://redis.io/commands/json.strlen/) | Report the length of the JSON String at path in key | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n| [JSON.TOGGLE](https://redis.io/commands/json.toggle/) | Toggle the boolean value stored at path | O(1) when path is evaluated to a single value, ... | 2.0.0 |\n| [JSON.TYPE](https://redis.io/commands/json.type/) | Report the type of JSON value at path | O(1) when path is evaluated to a single value, ... | 1.0.0 |\n\n\n\n[![Discord](https://img.shields.io/discord/697882427875393627?style=flat-square)](https://discord.gg/QUkjSsk)\n[![Github](https://img.shields.io/static/v1?label=&message=repository&color=5961FF&logo=github)](https://github.com/RedisJSON/RedisJSON/)\n\nThe JSON capability of Redis Open Source provides JavaScript Object Notation (JSON) support for Redis. It lets you store, update, and retrieve JSON values in a Redis database, similar to any other Redis data type. Redis JSON also works seamlessly with [Redis Search](https://redis.io/docs/latest/develop/ai/search-and-query) to let you [index and query JSON documents](https://redis.io/docs/latest/develop/ai/search-and-query/indexing)."
    },
    {
      "id": "primary-features",
      "title": "Primary features",
      "role": "content",
      "text": "* Full support for the JSON standard\n* A [JSONPath](http://goessner.net/articles/JsonPath/) syntax for selecting/updating elements inside documents (see [JSONPath syntax](https://redis.io/docs/latest/develop/data-types/json/path#jsonpath-syntax))\n* Documents stored as binary data in a tree structure, allowing fast access to sub-elements\n* Typed atomic operations for all JSON value types"
    },
    {
      "id": "use-redis-with-json",
      "title": "Use Redis with JSON",
      "role": "content",
      "text": "The first JSON command to try is [`JSON.SET`](https://redis.io/docs/latest/commands/json.set), which sets a Redis key with a JSON value. [`JSON.SET`](https://redis.io/docs/latest/commands/json.set) accepts all JSON value types. This example creates a JSON string:\n\nFoundational: Set and retrieve JSON values using JSON.SET and JSON.GET to store and access JSON documents\n\n**Commands:** JSON.SET, JSON.GET, JSON.TYPE\n\n**Complexity:**\n- JSON.SET: O(M+N)\n- JSON.GET: O(N)\n- JSON.TYPE: O(1)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]\n\n\n\nNote how the commands include the dollar sign character `$`. This is the [path](https://redis.io/docs/latest/develop/data-types/json/path) to the value in the JSON document (in this case it just means the root).\n\nHere are a few more string operations. [`JSON.STRLEN`](https://redis.io/docs/latest/commands/json.strlen) tells you the length of the string, and you can append another string to it with [`JSON.STRAPPEND`](https://redis.io/docs/latest/commands/json.strappend).\n\nString operations: Manipulate JSON strings using JSON.STRLEN to get length and JSON.STRAPPEND to concatenate values\n\n**Builds upon:** set_get\n\n**Commands:** JSON.STRLEN, JSON.STRAPPEND, JSON.GET\n\n**Complexity:**\n- JSON.STRLEN: O(1)\n- JSON.STRAPPEND: O(1)\n- JSON.GET: O(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]\n\n\n\nNumbers can be [incremented](https://redis.io/docs/latest/commands/json.numincrby) and [multiplied](https://redis.io/docs/latest/commands/json.nummultby):\n\nNumeric operations: Perform atomic arithmetic on JSON numbers using JSON.NUMINCRBY to increment and JSON.NUMMULTBY to multiply values\n\n**Builds upon:** set_get\n\n**Commands:** JSON.SET, JSON.NUMINCRBY, JSON.NUMMULTBY\n\n**Complexity:**\n- JSON.SET: O(M+N)\n- JSON.NUMINCRBY: O(1)\n- JSON.NUMMULTBY: O(1)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]\n\n\n\nHere's a more interesting example that includes JSON arrays and objects:\n\nArrays and objects: Work with complex JSON structures using JSONPath to access nested elements and JSON.DEL to remove values\n\n**Difficulty:** Intermediate\n\n**Builds upon:** set_get\n\n**Commands:** JSON.SET, JSON.GET, JSON.DEL\n\n**Complexity:**\n- JSON.SET: O(M+N)\n- JSON.GET: O(N)\n- JSON.DEL: O(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]\n\n\n\nBeginning with Redis 8.8, the JSON data type supports the ability to force a particular type when storing floating point homogeneous arrays (FPHAs)using the `FPHA BF16|FP16|FP32|FP64` option to the [`JSON.SET`](https://redis.io/docs/latest/commands/json.set) command. Here's an example:\n\n[code example]\n\nThe [`JSON.DEL`](https://redis.io/docs/latest/commands/json.del) command deletes any JSON value you specify with the `path` parameter.\n\nYou can manipulate arrays with a dedicated subset of JSON commands:\n\nArray manipulation: Use JSON.ARRAPPEND to add elements, JSON.ARRINSERT to insert at positions, JSON.ARRTRIM to keep ranges, and JSON.ARRPOP to remove elements\n\n**Difficulty:** Intermediate\n\n**Builds upon:** arr\n\n**Commands:** JSON.SET, JSON.ARRAPPEND, JSON.GET, JSON.ARRINSERT, JSON.ARRTRIM, JSON.ARRPOP\n\n**Complexity:**\n- JSON.SET: O(M+N)\n- JSON.ARRAPPEND: O(1)\n- JSON.GET: O(N)\n- JSON.ARRINSERT: O(N)\n- JSON.ARRTRIM: O(N)\n- JSON.ARRPOP: O(N)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]\n\n\n\nJSON objects also have their own commands:\n\nObject operations: Inspect JSON objects using JSON.OBJLEN to count fields and JSON.OBJKEYS to retrieve all keys\n\n**Difficulty:** Intermediate\n\n**Builds upon:** arr\n\n**Commands:** JSON.SET, JSON.OBJLEN, JSON.OBJKEYS\n\n**Complexity:**\n- JSON.SET: O(M+N)\n- JSON.OBJLEN: O(1)\n- JSON.OBJKEYS: O(1)\n\n**Available in:** Redis CLI, C#, Go, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]"
    },
    {
      "id": "format-cli-output",
      "title": "Format CLI output",
      "role": "content",
      "text": "The CLI has a raw output mode that lets you add formatting to the output from\n[`JSON.GET`](https://redis.io/docs/latest/commands/json.get) to make\nit more readable. To use this, run `redis-cli` with the `--raw` option\nand include formatting keywords such as `INDENT`, `NEWLINE`, and `SPACE`\nwith [`JSON.GET`](https://redis.io/docs/latest/commands/json.get):\n\n[code example]"
    },
    {
      "id": "enable-redis-json",
      "title": "Enable Redis JSON",
      "role": "content",
      "text": "The Redis JSON data type is part of Redis Open Source and it is also available in Redis Software and Redis Cloud.\nSee\n[Install Redis Open Source](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack) or\n[Install Redis Software](https://redis.io/docs/latest/operate/rs/installing-upgrading/install)\nfor full installation instructions."
    },
    {
      "id": "limitation",
      "title": "Limitation",
      "role": "limits",
      "text": "A JSON value passed to a command can have a depth of up to 128. If you pass to a command a JSON value that contains an object or an array with a nesting level of more than 128, the command returns an error."
    },
    {
      "id": "further-information",
      "title": "Further information",
      "role": "content",
      "text": "Read the other pages in this section to learn more about Redis JSON"
    }
  ],
  "examples": [
    {
      "id": "use-redis-with-json-ex0",
      "language": "plaintext",
      "code": "> JSON.SET bike $ '\"Hyperion\"'\nOK\n> JSON.GET bike $\n\"[\\\"Hyperion\\\"]\"\n> JSON.TYPE bike $\n1) \"string\"",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex1",
      "language": "csharp",
      "code": "bool res1 = db.JSON().Set(\"bike\", \"$\", \"\\\"Hyperion\\\"\");\n        Console.WriteLine(res1);    // >>> True\n\n        RedisResult res2 = db.JSON().Get(\"bike\", path: \"$\");\n        Console.WriteLine(res2);    // >>> [\"Hyperion\"]\n\n        JsonType[] res3 = db.JSON().Type(\"bike\", \"$\");\n        Console.WriteLine(string.Join(\", \", res3)); // >>> STRING",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex2",
      "language": "go",
      "code": "res1, err := rdb.JSONSet(ctx, \"bike\", \"$\",\n\t\t\"\\\"Hyperion\\\"\",\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res1) // >>> OK\n\n\tres2, err := rdb.JSONGet(ctx, \"bike\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res2) // >>> [\"Hyperion\"]\n\n\tres3, err := rdb.JSONType(ctx, \"bike\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res3) // >>> [[string]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex3",
      "language": "java",
      "code": "CompletableFuture<Void> setget = asyncCommands\n                    .jsonSet(\"bike\", JsonPath.ROOT_PATH, parser.createJsonValue(\"\\\"Hyperion\\\"\")).thenCompose(res1 -> {\n                        System.out.println(res1); // OK\n\n                        return asyncCommands.jsonGet(\"bike\", JsonPath.ROOT_PATH);\n                    }).thenCompose(res2 -> {\n                        System.out.println(res2); // >>> [[\"Hyperion\"]]\n\n                        return asyncCommands.jsonType(\"bike\", JsonPath.ROOT_PATH);\n                    })\n                    .thenAccept(System.out::println)\n                    // >>> [STRING]\n                    .toCompletableFuture();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex4",
      "language": "java",
      "code": "Mono<Void> setget = reactiveCommands.jsonSet(\"bike\", JsonPath.ROOT_PATH, parser.createJsonValue(\"\\\"Hyperion\\\"\"))\n                    .doOnNext(res1 -> {\n                        System.out.println(res1); // OK\n                    }).flatMap(res1 -> reactiveCommands.jsonGet(\"bike\", JsonPath.ROOT_PATH).collectList()).doOnNext(res2 -> {\n                        System.out.println(res2); // >>> [[\"Hyperion\"]]\n                    }).flatMap(res2 -> reactiveCommands.jsonType(\"bike\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(System.out::println) // >>> [STRING]\n                    .then();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex5",
      "language": "java",
      "code": "String res1 = jedis.jsonSet(\"bike\", new Path2(\"$\"), \"\\\"Hyperion\\\"\");\n        System.out.println(res1);   // >>> OK\n\n        Object res2 = jedis.jsonGet(\"bike\", new Path2(\"$\"));\n        System.out.println(res2);   // >>> [\"Hyperion\"]\n\n        List<Class<?>> res3 = jedis.jsonType(\"bike\", new Path2(\"$\"));\n        System.out.println(res3);   // >>> [class java.lang.String]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex6",
      "language": "javascript",
      "code": "const res1 = await client.json.set(\"bike\", \"$\", '\"Hyperion\"');\nconsole.log(res1); // OK\n\nconst res2 = await client.json.get(\"bike\", { path: \"$\" });\nconsole.log(res2); // ['\"Hyperion\"']\n\nconst res3 = await client.json.type(\"bike\", { path: \"$\" });\nconsole.log(res3); //  [ 'string' ]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex7",
      "language": "php",
      "code": "$res1 = $r->jsonset('bike', '$', '\"Hyperion\"');\n        echo $res1 . PHP_EOL;\n        // >>> OK\n\n        $res2 = $r->jsonget('bike', '', '', '', '$');\n        echo $res2 . PHP_EOL;\n        // >>> [\"Hyperion\"]\n\n        $res3 = $r->jsontype('bike', '$');\n        echo json_encode($res3) . PHP_EOL;\n        // >>> [\"string\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex8",
      "language": "python",
      "code": "res1 = r.json().set(\"bike\", \"$\", '\"Hyperion\"')\nprint(res1)  # >>> True\n\nres2 = r.json().get(\"bike\", \"$\")\nprint(res2)  # >>> ['\"Hyperion\"']\n\nres3 = r.json().type(\"bike\", \"$\")\nprint(res3)  # >>> ['string']",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex9",
      "language": "ruby",
      "code": "res1 = r.json_set('bike', '$', 'Hyperion')\nputs res1 # >>> OK\n\nres2 = r.json_get('bike', '$')\np res2 # >>> [\"Hyperion\"]\n\nres3 = r.json_type('bike', '$')\np res3 # >>> [\"string\"]\n\n# With raw: true, json_set accepts an already-encoded JSON string (skipping\n# serialization) and json_get returns the unparsed JSON string rather than a\n# Ruby object — useful when you store or forward plain JSON.\nres_raw1 = r.json_set('bike', '$', '\"Hyperion\"', raw: true)\nputs res_raw1 # >>> OK\n\nres_raw2 = r.json_get('bike', '$', raw: true)\nputs res_raw2 # >>> [\"Hyperion\"]  (a JSON string, not a Ruby array)",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex10",
      "language": "rust",
      "code": "let res1: bool = r\n            .json_set(\"bike\", \"$\", &json!(\"Hyperion\"))\n            .await\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res1); // >>> OK\n\n        let res2: String = r\n            .json_get(\"bike\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res2}\"); // >>> [\"Hyperion\"]\n\n        let res3: Value = r\n            .json_type(\"bike\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.TYPE\");\n        print_redis_value(&res3); // >>> [\"string\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex11",
      "language": "rust",
      "code": "let res1: bool = r\n            .json_set(\"bike\", \"$\", &json!(\"Hyperion\"))\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res1); // >>> OK\n\n        let res2: String = r.json_get(\"bike\", \"$\").expect(\"Failed to run JSON.GET\");\n        println!(\"{res2}\"); // >>> [\"Hyperion\"]\n\n        let res3: Value = r.json_type(\"bike\", \"$\").expect(\"Failed to run JSON.TYPE\");\n        print_redis_value(&res3); // >>> [\"string\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex12",
      "language": "plaintext",
      "code": "> JSON.STRLEN bike $\n1) (integer) 8\n> JSON.STRAPPEND bike $ '\" (Enduro bikes)\"'\n1) (integer) 23\n> JSON.GET bike $\n\"[\\\"Hyperion (Enduro bikes)\\\"]\"",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex13",
      "language": "csharp",
      "code": "long?[] res4 = db.JSON().StrLen(\"bike\", \"$\");\n        Console.Write(string.Join(\", \", res4)); // >>> 8\n\n        long?[] res5 = db.JSON().StrAppend(\"bike\", \" (Enduro bikes)\");\n        Console.WriteLine(string.Join(\", \", res5)); // >>> 23\n\n        RedisResult res6 = db.JSON().Get(\"bike\", path: \"$\");\n        Console.WriteLine(res6);    // >>> [\"Hyperion (Enduro bikes)\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex14",
      "language": "go",
      "code": "res4, err := rdb.JSONStrLen(ctx, \"bike\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(*res4[0]) // >>> 8\n\n\tres5, err := rdb.JSONStrAppend(ctx, \"bike\", \"$\", \"\\\" (Enduro bikes)\\\"\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(*res5[0]) // >>> 23\n\n\tres6, err := rdb.JSONGet(ctx, \"bike\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res6) // >>> [\"Hyperion (Enduro bikes)\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex15",
      "language": "java",
      "code": "CompletableFuture<Void> str = asyncCommands.jsonStrlen(\"bike\", JsonPath.ROOT_PATH).thenCompose(res3 -> {\n                System.out.println(res3); // >>> [8]\n\n                return asyncCommands.jsonStrappend(\"bike\", JsonPath.ROOT_PATH, parser.createJsonValue(\"\\\" (Enduro bikes)\\\"\"));\n            }).thenCompose(res4 -> {\n                System.out.println(res4); // >>> [23]\n\n                return asyncCommands.jsonGet(\"bike\", JsonPath.ROOT_PATH);\n            })\n                    .thenAccept(System.out::println)\n                    // >>> [[\"Hyperion (Enduro bikes)\"]]\n                    .toCompletableFuture();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex16",
      "language": "java",
      "code": "Mono<Void> str = reactiveCommands.jsonStrlen(\"bike\", JsonPath.ROOT_PATH).collectList().doOnNext(res3 -> {\n                System.out.println(res3); // >>> [8]\n            }).flatMap(res3 -> reactiveCommands\n                    .jsonStrappend(\"bike\", JsonPath.ROOT_PATH, parser.createJsonValue(\"\\\" (Enduro bikes)\\\"\")).collectList())\n                    .doOnNext(res4 -> {\n                        System.out.println(res4); // >>> [23]\n                    }).flatMap(res4 -> reactiveCommands.jsonGet(\"bike\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(System.out::println) // >>> [[\"Hyperion (Enduro bikes)\"]]\n                    .then();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex17",
      "language": "java",
      "code": "List<Long> res4 = jedis.jsonStrLen(\"bike\", new Path2(\"$\"));\n        System.out.println(res4);   // >>> [8]\n\n        List<Long> res5 = jedis.jsonStrAppend(\"bike\", new Path2(\"$\"), \" (Enduro bikes)\");\n        System.out.println(res5);   // >>> [23]\n\n        Object res6 = jedis.jsonGet(\"bike\", new Path2(\"$\"));\n        System.out.println(res6);   // >>> [\"Hyperion (Enduro bikes)\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex18",
      "language": "javascript",
      "code": "const res4 = await client.json.strLen(\"bike\", { path: \"$\" });\nconsole.log(res4) //  [10]\n\nconst res5 = await client.json.strAppend(\"bike\", '\" (Enduro bikes)\"');\nconsole.log(res5) //  27\n\nconst res6 = await client.json.get(\"bike\", { path: \"$\" });\nconsole.log(res6) //  ['\"Hyperion\"\" (Enduro bikes)\"']",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex19",
      "language": "php",
      "code": "$res4 = $r->jsonstrlen('bike', '$');\n        echo json_encode($res4) . PHP_EOL;\n        // >>> [8]\n\n        $res5 = $r->jsonstrappend('bike', '$', '\" (Enduro bikes)\"');\n        echo json_encode($res5) . PHP_EOL;\n        // >>> [23]\n\n        $res6 = $r->jsonget('bike', '', '', '', '$');\n        echo $res6 . PHP_EOL;\n        // >>> \"Hyperion (Enduro bikes)\"",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex20",
      "language": "python",
      "code": "res4 = r.json().strlen(\"bike\", \"$\")\nprint(res4)  # >>> [10]\n\nres5 = r.json().strappend(\"bike\", '\" (Enduro bikes)\"')\nprint(res5)  # >>> 27\n\nres6 = r.json().get(\"bike\", \"$\")\nprint(res6)  # >>> ['\"Hyperion\"\" (Enduro bikes)\"']",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex21",
      "language": "ruby",
      "code": "res4 = r.json_strlen('bike', '$')\np res4 # >>> [8]\n\nres5 = r.json_strappend('bike', '$', ' (Enduro bikes)')\np res5 # >>> [23]\n\nres6 = r.json_get('bike', '$')\np res6 # >>> [\"Hyperion (Enduro bikes)\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex22",
      "language": "rust",
      "code": "let res4: Value = r\n            .json_str_len(\"bike\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.STRLEN\");\n        print_redis_value(&res4); // >>> [8]\n\n        let res5: Value = r\n            .json_str_append(\"bike\", \"$\", \"\\\" (Enduro bikes)\\\"\")\n            .await\n            .expect(\"Failed to run JSON.STRAPPEND\");\n        print_redis_value(&res5); // >>> [23]\n\n        let res6: String = r\n            .json_get(\"bike\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res6}\"); // >>> [\"Hyperion (Enduro bikes)\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex23",
      "language": "rust",
      "code": "let res4: Value = r\n            .json_str_len(\"bike\", \"$\")\n            .expect(\"Failed to run JSON.STRLEN\");\n        print_redis_value(&res4); // >>> [8]\n\n        let res5: Value = r\n            .json_str_append(\"bike\", \"$\", \"\\\" (Enduro bikes)\\\"\")\n            .expect(\"Failed to run JSON.STRAPPEND\");\n        print_redis_value(&res5); // >>> [23]\n\n        let res6: String = r.json_get(\"bike\", \"$\").expect(\"Failed to run JSON.GET\");\n        println!(\"{res6}\"); // >>> [\"Hyperion (Enduro bikes)\"]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex24",
      "language": "plaintext",
      "code": "> JSON.SET crashes $ 0\nOK\n> JSON.NUMINCRBY crashes $ 1\n\"[1]\"\n> JSON.NUMINCRBY crashes $ 1.5\n\"[2.5]\"\n> JSON.NUMINCRBY crashes $ -0.75\n\"[1.75]\"\n> JSON.NUMMULTBY crashes $ 24\n\"[42.0]\"",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex25",
      "language": "csharp",
      "code": "bool res7 = db.JSON().Set(\"crashes\", \"$\", 0);\n        Console.WriteLine(res7);    // >>> True\n\n        double?[] res8 = db.JSON().NumIncrby(\"crashes\", \"$\", 1);\n        Console.WriteLine(string.Join(\", \", res8));    // >>> 1\n\n        double?[] res9 = db.JSON().NumIncrby(\"crashes\", \"$\", 1.5);\n        Console.WriteLine(string.Join(\", \", res9));    // >>> 2.5\n\n        double?[] res10 = db.JSON().NumIncrby(\"crashes\", \"$\", -0.75);\n        Console.WriteLine(string.Join(\", \", res10));    // >>> 1.75",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex26",
      "language": "go",
      "code": "res7, err := rdb.JSONSet(ctx, \"crashes\", \"$\", 0).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res7) // >>> OK\n\n\tres8, err := rdb.JSONNumIncrBy(ctx, \"crashes\", \"$\", 1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res8) // >>> [1]\n\n\tres9, err := rdb.JSONNumIncrBy(ctx, \"crashes\", \"$\", 1.5).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res9) // >>> [2.5]\n\n\tres10, err := rdb.JSONNumIncrBy(ctx, \"crashes\", \"$\", -0.75).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res10) // >>> [1.75]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex27",
      "language": "java",
      "code": "CompletableFuture<Void> num = asyncCommands.jsonSet(\"crashes\", JsonPath.ROOT_PATH, parser.createJsonValue(\"0\"))\n                    .thenCompose(res5 -> {\n                        System.out.println(res5); // >>> OK\n\n                        return asyncCommands.jsonNumincrby(\"crashes\", JsonPath.ROOT_PATH, 1);\n                    }).thenCompose(res6 -> {\n                        System.out.println(res6); // >>> [1]\n\n                        return asyncCommands.jsonNumincrby(\"crashes\", JsonPath.ROOT_PATH, 1.5);\n                    }).thenCompose(res7 -> {\n                        System.out.println(res7); // >>> [2.5]\n\n                        return asyncCommands.jsonNumincrby(\"crashes\", JsonPath.ROOT_PATH, -0.75);\n                    })\n                    .thenAccept(System.out::println) // >>> [1.75]\n                    .toCompletableFuture();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex28",
      "language": "java",
      "code": "Mono<Void> num = reactiveCommands.jsonSet(\"crashes\", JsonPath.ROOT_PATH, parser.createJsonValue(\"0\"))\n                    .doOnNext(res5 -> {\n                        System.out.println(res5); // >>> OK\n                    }).flatMap(res5 -> reactiveCommands.jsonNumincrby(\"crashes\", JsonPath.ROOT_PATH, 1).collectList())\n                    .doOnNext(res6 -> {\n                        System.out.println(res6); // >>> [1]\n                    }).flatMap(res6 -> reactiveCommands.jsonNumincrby(\"crashes\", JsonPath.ROOT_PATH, 1.5).collectList())\n                    .doOnNext(res7 -> {\n                        System.out.println(res7); // >>> [2.5]\n                    }).flatMap(res7 -> reactiveCommands.jsonNumincrby(\"crashes\", JsonPath.ROOT_PATH, -0.75).collectList())\n                    .doOnNext(System.out::println) // >>> [1.75]\n                    .then();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex29",
      "language": "java",
      "code": "String res7 = jedis.jsonSet(\"crashes\", new Path2(\"$\"), 0);\n        System.out.println(res7);   // >>> OK\n\n        Object res8 = jedis.jsonNumIncrBy(\"crashes\", new Path2(\"$\"), 1);\n        System.out.println(res8);   // >>> [1]\n\n        Object res9 = jedis.jsonNumIncrBy(\"crashes\", new Path2(\"$\"), 1.5);\n        System.out.println(res9);   // >>> [2.5]\n\n        Object res10 = jedis.jsonNumIncrBy(\"crashes\", new Path2(\"$\"), -0.75);\n        System.out.println(res10);   // >>> [1.75]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex30",
      "language": "javascript",
      "code": "const res7 = await client.json.set(\"crashes\", \"$\", 0);\nconsole.log(res7) //  OK\n\nconst res8 = await client.json.numIncrBy(\"crashes\", \"$\", 1);\nconsole.log(res8) //  [1]\n\nconst res9 = await client.json.numIncrBy(\"crashes\", \"$\", 1.5);\nconsole.log(res9) //  [2.5]\n\nconst res10 = await client.json.numIncrBy(\"crashes\", \"$\", -0.75);\nconsole.log(res10) //  [1.75]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex31",
      "language": "php",
      "code": "$res7 = $r->jsonset('crashes', '$', '0');\n        echo $res7 . PHP_EOL;\n        // >>> OK\n\n        $res8 = $r->jsonnumincrby('crashes', '$', 1);\n        echo $res8 . PHP_EOL;\n        // >>> [1]\n\n        $res9 = $r->jsonnumincrby('crashes', '$', 1.5);\n        echo $res9 . PHP_EOL;\n        // >>> [2.5]\n\n        $res10 = $r->jsonnumincrby('crashes', '$', -0.75);\n        echo $res10 . PHP_EOL;\n        // >>> [1.75]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex32",
      "language": "python",
      "code": "res7 = r.json().set(\"crashes\", \"$\", 0)\nprint(res7)  # >>> True\n\nres8 = r.json().numincrby(\"crashes\", \"$\", 1)\nprint(res8)  # >>> [1]\n\nres9 = r.json().numincrby(\"crashes\", \"$\", 1.5)\nprint(res9)  # >>> [2.5]\n\nres10 = r.json().numincrby(\"crashes\", \"$\", -0.75)\nprint(res10)  # >>> [1.75]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex33",
      "language": "ruby",
      "code": "res7 = r.json_set('crashes', '$', 0)\nputs res7 # >>> OK\n\nres8 = r.json_numincrby('crashes', '$', 1)\np res8 # >>> [1]\n\nres9 = r.json_numincrby('crashes', '$', 1.5)\np res9 # >>> [2.5]\n\nres10 = r.json_numincrby('crashes', '$', -0.75)\np res10 # >>> [1.75]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex34",
      "language": "rust",
      "code": "let res7: bool = r\n            .json_set(\"crashes\", \"$\", &json!(0))\n            .await\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res7); // >>> OK\n\n        let res8: String = cmd(\"JSON.NUMINCRBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(1)\n            .query_async(&mut r)\n            .await\n            .expect(\"Failed to run JSON.NUMINCRBY\");\n        println!(\"{res8}\"); // >>> [1]\n\n        let res9: String = cmd(\"JSON.NUMINCRBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(1.5)\n            .query_async(&mut r)\n            .await\n            .expect(\"Failed to run JSON.NUMINCRBY\");\n        println!(\"{res9}\"); // >>> [2.5]\n\n        let res10: String = cmd(\"JSON.NUMINCRBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(-0.75)\n            .query_async(&mut r)\n            .await\n            .expect(\"Failed to run JSON.NUMINCRBY\");\n        println!(\"{res10}\"); // >>> [1.75]\n\n        let res11: String = cmd(\"JSON.NUMMULTBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(24)\n            .query_async(&mut r)\n            .await\n            .expect(\"Failed to run JSON.NUMMULTBY\");\n        println!(\"{res11}\"); // >>> [42.0]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex35",
      "language": "rust",
      "code": "let res7: bool = r\n            .json_set(\"crashes\", \"$\", &json!(0))\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res7); // >>> OK\n\n        let res8: String = cmd(\"JSON.NUMINCRBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(1)\n            .query(&mut r)\n            .expect(\"Failed to run JSON.NUMINCRBY\");\n        println!(\"{res8}\"); // >>> [1]\n\n        let res9: String = cmd(\"JSON.NUMINCRBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(1.5)\n            .query(&mut r)\n            .expect(\"Failed to run JSON.NUMINCRBY\");\n        println!(\"{res9}\"); // >>> [2.5]\n\n        let res10: String = cmd(\"JSON.NUMINCRBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(-0.75)\n            .query(&mut r)\n            .expect(\"Failed to run JSON.NUMINCRBY\");\n        println!(\"{res10}\"); // >>> [1.75]\n\n        let res11: String = cmd(\"JSON.NUMMULTBY\")\n            .arg(\"crashes\")\n            .arg(\"$\")\n            .arg(24)\n            .query(&mut r)\n            .expect(\"Failed to run JSON.NUMMULTBY\");\n        println!(\"{res11}\"); // >>> [42.0]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex36",
      "language": "plaintext",
      "code": "> JSON.SET newbike $ '[\"Deimos\", {\"crashes\": 0}, null]'\nOK\n> JSON.GET newbike $\n\"[[\\\"Deimos\\\",{\\\"crashes\\\":0},null]]\"\n> JSON.GET newbike $[1].crashes\n\"[0]\"\n> JSON.DEL newbike $[-1]\n(integer) 1\n> JSON.GET newbike $\n\"[[\\\"Deimos\\\",{\\\"crashes\\\":0}]]\"",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex37",
      "language": "csharp",
      "code": "bool res11 = db.JSON().Set(\"newbike\", \"$\", new object?[] { \"Deimos\", new { crashes = 0 }, null });\n        Console.WriteLine(res11);   // >>> True\n\n        RedisResult res12 = db.JSON().Get(\"newbike\", path: \"$\");\n        Console.WriteLine(res12);   //  >>> [[\"Deimos\",{\"crashes\":0},null]]\n\n        RedisResult res13 = db.JSON().Get(\"newbike\", path: \"$[1].crashes\");\n        Console.WriteLine(res13);   // >>> [0]\n\n        long res14 = db.JSON().Del(\"newbike\", \"$.[-1]\");\n        Console.WriteLine(res14);   // >>> 1\n\n        RedisResult res15 = db.JSON().Get(\"newbike\", path: \"$\");\n        Console.WriteLine(res15);   // >>> [[\"Deimos\",{\"crashes\":0}]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex38",
      "language": "go",
      "code": "res11, err := rdb.JSONSet(ctx, \"newbike\", \"$\",\n\t\t[]interface{}{\n\t\t\t\"Deimos\",\n\t\t\tmap[string]interface{}{\"crashes\": 0},\n\t\t\tnil,\n\t\t},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res11) // >>> OK\n\n\tres12, err := rdb.JSONGet(ctx, \"newbike\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res12) // >>> [[\"Deimos\",{\"crashes\":0},null]]\n\n\tres13, err := rdb.JSONGet(ctx, \"newbike\", \"$[1].crashes\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res13) // >>> [0]\n\n\tres14, err := rdb.JSONDel(ctx, \"newbike\", \"$.[-1]\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res14) // >>> 1\n\n\tres15, err := rdb.JSONGet(ctx, \"newbike\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res15) // >>> [[\"Deimos\",{\"crashes\":0}]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex39",
      "language": "java",
      "code": "JsonObject crashDetails = parser.createJsonObject();\n            crashDetails.put(\"crashes\", parser.createJsonValue(\"0\"));\n\n            JsonArray bikeDetails = parser.createJsonArray();\n            bikeDetails.add(parser.createJsonValue(\"\\\"Deimos\\\"\"));\n            bikeDetails.add(crashDetails);\n            bikeDetails.add(null);\n\n            CompletableFuture<Void> arr = asyncCommands.jsonSet(\"newbike\", JsonPath.ROOT_PATH, bikeDetails).thenCompose(r -> {\n                System.out.println(r); // >>> OK\n\n                return asyncCommands.jsonGet(\"newbike\", JsonPath.ROOT_PATH);\n            }).thenCompose(res8 -> {\n                System.out.println(res8);\n                // >>> [[\"Deimos\",{\"crashes\":0},null]]\n\n                return asyncCommands.jsonGet(\"newbike\", JsonPath.of(\"$[1].crashes\"));\n            }).thenCompose(res9 -> {\n                System.out.println(res9); // >>> [[0]]\n\n                return asyncCommands.jsonDel(\"newbike\", JsonPath.of(\"$.[-1]\"));\n            }).thenCompose(res10 -> {\n                System.out.println(res10); // >>> 1\n\n                return asyncCommands.jsonGet(\"newbike\", JsonPath.ROOT_PATH);\n            })\n                    .thenAccept(System.out::println)\n                    // >>> [[[\\\"Deimos\\\",{\\\"crashes\\\":0}]]]\n                    .toCompletableFuture();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex40",
      "language": "java",
      "code": "JsonObject crashDetails = parser.createJsonObject();\n            crashDetails.put(\"crashes\", parser.createJsonValue(\"0\"));\n\n            JsonArray bikeDetails = parser.createJsonArray();\n            bikeDetails.add(parser.createJsonValue(\"\\\"Deimos\\\"\"));\n            bikeDetails.add(crashDetails);\n            bikeDetails.add(null);\n\n            Mono<Void> arr = reactiveCommands.jsonSet(\"newbike\", JsonPath.ROOT_PATH, bikeDetails).doOnNext(r -> {\n                System.out.println(r); // >>> OK\n            }).flatMap(r -> reactiveCommands.jsonGet(\"newbike\", JsonPath.ROOT_PATH).collectList()).doOnNext(res8 -> {\n                System.out.println(res8);\n                // >>> [[\"Deimos\",{\"crashes\":0},null]]\n            }).flatMap(res8 -> reactiveCommands.jsonGet(\"newbike\", JsonPath.of(\"$[1].crashes\")).collectList())\n                    .doOnNext(res9 -> {\n                        System.out.println(res9); // >>> [[0]]\n                    }).flatMap(res9 -> reactiveCommands.jsonDel(\"newbike\", JsonPath.of(\"$.[-1]\"))).doOnNext(res10 -> {\n                        System.out.println(res10); // >>> 1\n                    }).flatMap(res10 -> reactiveCommands.jsonGet(\"newbike\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(System.out::println) // >>> [[[\\\"Deimos\\\",{\\\"crashes\\\":0}]]]\n                    .then();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex41",
      "language": "java",
      "code": "String res11 = jedis.jsonSet(\"newbike\", new Path2(\"$\"),\n            new JSONArray()\n                .put(\"Deimos\")\n                .put(new JSONObject().put(\"crashes\", 0))\n                .put((Object) null)\n        );\n        System.out.println(res11);  // >>> OK\n        \n        Object res12 = jedis.jsonGet(\"newbike\", new Path2(\"$\"));\n        System.out.println(res12);  // >>> [[\"Deimos\",{\"crashes\":0},null]]\n\n        Object res13 = jedis.jsonGet(\"newbike\", new Path2(\"$[1].crashes\"));\n        System.out.println(res13);  // >>> [0]\n\n        long res14 = jedis.jsonDel(\"newbike\", new Path2(\"$.[-1]\"));\n        System.out.println(res14);  // >>> 1\n\n        Object res15 = jedis.jsonGet(\"newbike\", new Path2(\"$\"));\n        System.out.println(res15);  // >>> [[\"Deimos\",{\"crashes\":0}]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex42",
      "language": "javascript",
      "code": "const res11 = await client.json.set(\"newbike\", \"$\", [\"Deimos\", {\"crashes\": 0 }, null]);\nconsole.log(res11); //  OK\n\nconst res12 = await client.json.get(\"newbike\", { path: \"$\" });\nconsole.log(res12); //  [[ 'Deimos', { crashes: 0 }, null ]]\n\nconst res13 = await client.json.get(\"newbike\", { path: \"$[1].crashes\" });\nconsole.log(res13); //  [0]\n\nconst res14 = await client.json.del(\"newbike\", { path: \"$.[-1]\"} );\nconsole.log(res14); //  1\n\nconst res15 = await client.json.get(\"newbike\", { path: \"$\" });\nconsole.log(res15); //  [[ 'Deimos', { crashes: 0 } ]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex43",
      "language": "php",
      "code": "$newbike = json_encode([\"Deimos\", [\"crashes\" => 0], null], JSON_THROW_ON_ERROR);\n        $res11 = $r->jsonset('newbike', '$', $newbike);\n        echo $res11 . PHP_EOL;\n        // >>> OK\n\n        $res12 = $r->jsonget('newbike', '', '', '', '$');\n        echo $res12 . PHP_EOL;\n        // >>> [[\"Deimos\",{\"crashes\":0},null]]\n\n        $res13 = $r->jsonget('newbike', '', '', '', '$[1].crashes');\n        echo $res13 . PHP_EOL;\n        // >>> 0\n\n        $res14 = $r->jsondel('newbike', '$.[-1]');\n        echo $res14 . PHP_EOL;\n        // >>> 1\n\n        $res15 = $r->jsonget('newbike', '', '', '', '$');\n        echo $res15 . PHP_EOL;\n        // >>> [\"Deimos\",{\"crashes\":0}]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex44",
      "language": "python",
      "code": "res11 = r.json().set(\"newbike\", \"$\", [\"Deimos\", {\"crashes\": 0}, None])\nprint(res11)  # >>> True\n\nres12 = r.json().get(\"newbike\", \"$\")\nprint(res12)  # >>> ['[\"Deimos\", { \"crashes\": 0 }, null]']\n\nres13 = r.json().get(\"newbike\", \"$[1].crashes\")\nprint(res13)  # >>> [0]\n\nres14 = r.json().delete(\"newbike\", \"$.[-1]\")\nprint(res14)  # >>> [1]\n\nres15 = r.json().get(\"newbike\", \"$\")\nprint(res15)  # >>> [['Deimos', {'crashes': 0}]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex45",
      "language": "ruby",
      "code": "res11 = r.json_set('newbike', '$', ['Deimos', { 'crashes' => 0 }, nil])\nputs res11 # >>> OK\n\nres12 = r.json_get('newbike', '$')\np res12 # >>> [[\"Deimos\", {\"crashes\"=>0}, nil]]\n\nres13 = r.json_get('newbike', '$[1].crashes')\np res13 # >>> [0]\n\nres14 = r.json_del('newbike', '$.[-1]')\np res14 # >>> 1\n\nres15 = r.json_get('newbike', '$')\np res15 # >>> [[\"Deimos\", {\"crashes\"=>0}]]\n\n# The same raw: true option returns the array as unparsed JSON text.\nres_raw3 = r.json_get('newbike', '$', raw: true)\nputs res_raw3 # >>> [[\"Deimos\",{\"crashes\":0}]]  (a JSON string)",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex46",
      "language": "rust",
      "code": "let res12: bool = r\n            .json_set(\"newbike\", \"$\", &json!([\"Deimos\", {\"crashes\": 0}, null]))\n            .await\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res12); // >>> OK\n\n        let res13: String = r\n            .json_get(\"newbike\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res13}\"); // >>> [[\"Deimos\",{\"crashes\":0},null]]\n\n        let res14: String = r\n            .json_get(\"newbike\", \"$[1].crashes\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res14}\"); // >>> [0]\n\n        let res15: i64 = r\n            .json_del(\"newbike\", \"$[-1]\")\n            .await\n            .expect(\"Failed to run JSON.DEL\");\n        println!(\"{res15}\"); // >>> 1\n\n        let res16: String = r\n            .json_get(\"newbike\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res16}\"); // >>> [[\"Deimos\",{\"crashes\":0}]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex47",
      "language": "rust",
      "code": "let res12: bool = r\n            .json_set(\"newbike\", \"$\", &json!([\"Deimos\", {\"crashes\": 0}, null]))\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res12); // >>> OK\n\n        let res13: String = r.json_get(\"newbike\", \"$\").expect(\"Failed to run JSON.GET\");\n        println!(\"{res13}\"); // >>> [[\"Deimos\",{\"crashes\":0},null]]\n\n        let res14: String = r\n            .json_get(\"newbike\", \"$[1].crashes\")\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res14}\"); // >>> [0]\n\n        let res15: i64 = r\n            .json_del(\"newbike\", \"$[-1]\")\n            .expect(\"Failed to run JSON.DEL\");\n        println!(\"{res15}\"); // >>> 1\n\n        let res16: String = r.json_get(\"newbike\", \"$\").expect(\"Failed to run JSON.GET\");\n        println!(\"{res16}\"); // >>> [[\"Deimos\",{\"crashes\":0}]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex48",
      "language": "plaintext",
      "code": "> JSON.SET fp_array $ '[[1,2,3,4e3],[5,6.0,7,8]]' FPHA FP16\nOK\n> JSON.GET fp_array $\n\"[[[1.0,2.0,3.0,4000.0],[5.0,6.0,7.0,8.0]]]\"",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex49",
      "language": "plaintext",
      "code": "> JSON.SET riders $ []\nOK\n> JSON.ARRAPPEND riders $ '\"Norem\"'\n1) (integer) 1\n> JSON.GET riders $\n\"[[\\\"Norem\\\"]]\"\n> JSON.ARRINSERT riders $ 1 '\"Prickett\"' '\"Royce\"' '\"Castilla\"'\n1) (integer) 4\n> JSON.GET riders $\n\"[[\\\"Norem\\\",\\\"Prickett\\\",\\\"Royce\\\",\\\"Castilla\\\"]]\"\n> JSON.ARRTRIM riders $ 1 1\n1) (integer) 1\n> JSON.GET riders $\n\"[[\\\"Prickett\\\"]]\"\n> JSON.ARRPOP riders $\n1) \"\\\"Prickett\\\"\"\n> JSON.ARRPOP riders $\n1) (nil)",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex50",
      "language": "csharp",
      "code": "bool res16 = db.JSON().Set(\"riders\", \"$\", new object[] { });\n        Console.WriteLine(res16);   // >>> True\n\n        long?[] res17 = db.JSON().ArrAppend(\"riders\", \"$\", \"Norem\");\n        Console.WriteLine(string.Join(\", \", res17));    // >>> 1\n\n        RedisResult res18 = db.JSON().Get(\"riders\", path: \"$\");\n        Console.WriteLine(res18);   // >>> [[\"Norem\"]]\n\n        long?[] res19 = db.JSON().ArrInsert(\"riders\", \"$\", 1, \"Prickett\", \"Royce\", \"Castilla\");\n        Console.WriteLine(string.Join(\", \", res19));    // >>> 4\n\n        RedisResult res20 = db.JSON().Get(\"riders\", path: \"$\");\n        Console.WriteLine(res20);   // >>> [[\"Norem\",\"Prickett\",\"Royce\",\"Castilla\"]]\n\n        long?[] res21 = db.JSON().ArrTrim(\"riders\", \"$\", 1, 1);\n        Console.WriteLine(string.Join(\", \", res21));    // 1\n\n        RedisResult res22 = db.JSON().Get(\"riders\", path: \"$\");\n        Console.WriteLine(res22);   // >>> [[\"Prickett\"]]\n\n        RedisResult[] res23 = db.JSON().ArrPop(\"riders\", \"$\");\n        Console.WriteLine(string.Join(\", \", (object[])res23)); // >>> \"Prickett\"\n\n        RedisResult[] res24 = db.JSON().ArrPop(\"riders\", \"$\");\n        Console.WriteLine(string.Join(\", \", (object[])res24)); // >>> <Empty string>",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex51",
      "language": "go",
      "code": "res16, err := rdb.JSONSet(ctx, \"riders\", \"$\", []interface{}{}).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res16) // >>> OK\n\n\tres17, err := rdb.JSONArrAppend(ctx, \"riders\", \"$\", \"\\\"Norem\\\"\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res17) // >>> [1]\n\n\tres18, err := rdb.JSONGet(ctx, \"riders\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res18) // >>> [[\"Norem\"]]\n\n\tres19, err := rdb.JSONArrInsert(ctx, \"riders\", \"$\", 1,\n\t\t\"\\\"Prickett\\\"\", \"\\\"Royce\\\"\", \"\\\"Castilla\\\"\",\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res19) // [3]\n\n\tres20, err := rdb.JSONGet(ctx, \"riders\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res20) // >>> [[\"Norem\", \"Prickett\", \"Royce\", \"Castilla\"]]\n\n\trangeStop := 1\n\n\tres21, err := rdb.JSONArrTrimWithArgs(ctx, \"riders\", \"$\",\n\t\t&redis.JSONArrTrimArgs{Start: 1, Stop: &rangeStop},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res21) // >>> [1]\n\n\tres22, err := rdb.JSONGet(ctx, \"riders\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res22) // >>> [[\"Prickett\"]]\n\n\tres23, err := rdb.JSONArrPop(ctx, \"riders\", \"$\", -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res23) // >>> [[\"Prickett\"]]\n\n\tres24, err := rdb.JSONArrPop(ctx, \"riders\", \"$\", -1).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res24) // []",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex52",
      "language": "java",
      "code": "CompletableFuture<Void> arr2 = asyncCommands.jsonSet(\"riders\", JsonPath.ROOT_PATH, parser.createJsonArray())\n                    .thenCompose(r -> {\n                        System.out.println(r); // >>> OK\n\n                        return asyncCommands.jsonArrinsert(\"riders\", JsonPath.ROOT_PATH, 0,\n                                parser.createJsonValue(\"\\\"Norem\\\"\"));\n                    }).thenCompose(res11 -> {\n                        System.out.println(res11); // >>> [1]\n\n                        return asyncCommands.jsonGet(\"riders\", JsonPath.ROOT_PATH);\n                    })\n\n                    .thenCompose(res12 -> {\n                        System.out.println(res12); // >>> [\"Norem\"]\n\n                        return asyncCommands.jsonArrinsert(\"riders\", JsonPath.ROOT_PATH, 1,\n                                parser.createJsonValue(\"\\\"Prickett\\\"\"), parser.createJsonValue(\"\\\"Royce\\\"\"),\n                                parser.createJsonValue(\"\\\"Castilla\\\"\"));\n                    }).thenCompose(res13 -> {\n                        System.out.println(res13); // >>> [4]\n\n                        return asyncCommands.jsonGet(\"riders\", JsonPath.ROOT_PATH);\n                    }).thenCompose(res14 -> {\n                        System.out.println(res14); // >>> [\"Norem\",\"Prickett\",\"Royce\",\"Castilla\"]\n                        //\n                        return asyncCommands.jsonArrtrim(\"riders\", JsonPath.ROOT_PATH, new JsonRangeArgs().start(1).stop(1));\n                    }).thenCompose(res15 -> {\n                        System.out.println(res15); // >>> [1]\n\n                        return asyncCommands.jsonGet(\"riders\", JsonPath.ROOT_PATH);\n                    }).thenCompose(res16 -> {\n                        System.out.println(res16); // >>> [[[\"Prickett\"]]]\n                        return asyncCommands.jsonArrpop(\"riders\", JsonPath.ROOT_PATH, 0);\n                    }).thenCompose(res17 -> {\n                        System.out.println(res17); // >>> [\"Prickett\"]\n                        return asyncCommands.jsonArrpop(\"riders\", JsonPath.ROOT_PATH);\n                    })\n                    .thenAccept(System.out::println)\n                    // >>> null\n                    .toCompletableFuture();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex53",
      "language": "java",
      "code": "Mono<Void> arr2 = reactiveCommands.jsonSet(\"riders\", JsonPath.ROOT_PATH, parser.createJsonArray()).doOnNext(r -> {\n                System.out.println(r); // >>> OK\n            }).flatMap(r -> reactiveCommands.jsonArrinsert(\"riders\", JsonPath.ROOT_PATH, 0, parser.createJsonValue(\"\\\"Norem\\\"\"))\n                    .collectList()).doOnNext(res11 -> {\n                        System.out.println(res11); // >>> [1]\n                    }).flatMap(res11 -> reactiveCommands.jsonGet(\"riders\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(res12 -> {\n                        System.out.println(res12); // >>> [\"Norem\"]\n                    })\n                    .flatMap(\n                            res12 -> reactiveCommands\n                                    .jsonArrinsert(\"riders\", JsonPath.ROOT_PATH, 1, parser.createJsonValue(\"\\\"Prickett\\\"\"),\n                                            parser.createJsonValue(\"\\\"Royce\\\"\"), parser.createJsonValue(\"\\\"Castilla\\\"\"))\n                                    .collectList())\n                    .doOnNext(res13 -> {\n                        System.out.println(res13); // >>> [4]\n                    }).flatMap(res13 -> reactiveCommands.jsonGet(\"riders\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(System.out::println) // >>> [[\"Norem\",\"Prickett\",\"Royce\",\"Castilla\"]]\n                    .flatMap(res14 -> reactiveCommands\n                            .jsonArrtrim(\"riders\", JsonPath.ROOT_PATH, new JsonRangeArgs().start(1).stop(1)).collectList())\n                    .doOnNext(res15 -> {\n                        System.out.println(res15); // >>> [1]\n                    }).flatMap(res15 -> reactiveCommands.jsonGet(\"riders\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(res16 -> {\n                        System.out.println(res16); // >>> [[[\"Prickett\"]]]\n                    }).flatMap(res16 -> reactiveCommands.jsonArrpop(\"riders\", JsonPath.ROOT_PATH, 0).collectList())\n                    .doOnNext(res17 -> {\n                        System.out.println(res17); // >>> [\"Prickett\"]\n                    }).flatMap(res17 -> reactiveCommands.jsonArrpop(\"riders\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(System.out::println) // >>> null\n                    .then();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex54",
      "language": "java",
      "code": "String res16 = jedis.jsonSet(\"riders\", new Path2(\"$\"), new JSONArray());\n        System.out.println(res16);  // >>> OK\n\n        List<Long> res17 = jedis.jsonArrAppendWithEscape(\"riders\", new Path2(\"$\"), \"Norem\");\n        System.out.println(res17);  // >>> [1]\n\n        Object res18 = jedis.jsonGet(\"riders\", new Path2(\"$\"));\n        System.out.println(res18);  // >>> [[\"Norem\"]]\n\n        List<Long> res19 = jedis.jsonArrInsertWithEscape(\n            \"riders\", new Path2(\"$\"), 1, \"Prickett\", \"Royce\", \"Castilla\"\n        );\n        System.out.println(res19);  // >>> [4]\n\n        Object res20 = jedis.jsonGet(\"riders\", new Path2(\"$\"));\n        System.out.println(res20);\n        // >>> [[\"Norem\",\"Prickett\",\"Royce\",\"Castilla\"]]\n        \n        List<Long> res21 = jedis.jsonArrTrim(\"riders\", new Path2(\"$\"), 1, 1);\n        System.out.println(res21);  // >>> [1]\n\n        Object res22 = jedis.jsonGet(\"riders\", new Path2(\"$\"));\n        System.out.println(res22);  // >>> [[\"Prickett\"]]\n\n        Object res23 = jedis.jsonArrPop(\"riders\", new Path2(\"$\"));\n        System.out.println(res23);  // >>> [Prickett]\n\n        Object res24 = jedis.jsonArrPop(\"riders\", new Path2(\"$\"));\n        System.out.println(res24);  // >>> [null]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex55",
      "language": "javascript",
      "code": "const res16 = await client.json.set(\"riders\", \"$\", []);\nconsole.log(res16); //  OK\n\nconst res17 = await client.json.arrAppend(\"riders\", \"$\", \"Norem\");\nconsole.log(res17); //  [1]\n\nconst res18 = await client.json.get(\"riders\", { path: \"$\" });\nconsole.log(res18); //  [[ 'Norem' ]]\n\nconst res19 = await client.json.arrInsert(\"riders\", \"$\", 1, \"Prickett\", \"Royse\", \"Castilla\");\nconsole.log(res19); //  [4]\n\nconst res20 = await client.json.get(\"riders\", { path: \"$\" });\nconsole.log(res20); //  [[ 'Norem', 'Prickett', 'Royse', 'Castilla' ]]\n\nconst res21 = await client.json.arrTrim(\"riders\", \"$\", 1, 1);\nconsole.log(res21); //  [1]\n\nconst res22 = await client.json.get(\"riders\", { path: \"$\" });\nconsole.log(res22); //  [[ 'Prickett' ]]\n\nconst res23 = await client.json.arrPop(\"riders\", { path: \"$\" });\nconsole.log(res23); //  [ 'Prickett' ]\n\nconst res24 = await client.json.arrPop(\"riders\", { path: \"$\" });\nconsole.log(res24); //  [null]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex56",
      "language": "php",
      "code": "$res16 = $r->jsonset('riders', '$', '[]');\n        echo $res16 . PHP_EOL;\n        // >>> OK\n\n        $res17 = $r->jsonarrappend('riders', '$', '\"Norem\"');\n        echo json_encode($res17) . PHP_EOL;\n        // >>> [1]\n\n        $res18 = $r->jsonget('riders', '', '', '', '$');\n        echo $res18 . PHP_EOL;\n        // >>> [\"Norem\"]\n\n        $res19 = $r->jsonarrinsert('riders', '$', 1, '\"Prickett\"', '\"Royce\"', '\"Castilla\"');\n        echo json_encode($res19) . PHP_EOL;\n        // >>> [4]\n\n        $res20 = $r->jsonget('riders', '', '', '', '$');\n        echo $res20 . PHP_EOL;\n        // >>> [\"Norem\",\"Prickett\",\"Royce\",\"Castilla\"]\n\n        $res21 = $r->jsonarrtrim('riders', '$', 1, 1);\n        echo json_encode($res21) . PHP_EOL;\n        // >>> [1]\n\n        $res22 = $r->jsonget('riders', '', '', '', '$');\n        echo $res22 . PHP_EOL;\n        // >>> [\"Prickett\"]\n\n        $res23 = $r->jsonarrpop('riders', '$');\n        echo json_encode($res23) . PHP_EOL;\n        // >>> [\"\\\"Prickett\\\"\"]\n\n        $res24 = $r->jsonarrpop('riders', '$');\n        echo json_encode($res24) . PHP_EOL;\n        // >>> [null]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex57",
      "language": "python",
      "code": "res16 = r.json().set(\"riders\", \"$\", [])\nprint(res16)  # >>> True\n\nres17 = r.json().arrappend(\"riders\", \"$\", \"Norem\")\nprint(res17)  # >>> [1]\n\nres18 = r.json().get(\"riders\", \"$\")\nprint(res18)  # >>> [['Norem']]\n\nres19 = r.json().arrinsert(\"riders\", \"$\", 1, \"Prickett\", \"Royce\", \"Castilla\")\nprint(res19)  # >>> [4]\n\nres20 = r.json().get(\"riders\", \"$\")\nprint(res20)  # >>> [['Norem', 'Prickett', 'Royce', 'Castilla']]\n\nres21 = r.json().arrtrim(\"riders\", \"$\", 1, 1)\nprint(res21)  # >>> [1]\n\nres22 = r.json().get(\"riders\", \"$\")\nprint(res22)  # >>> [['Prickett']]\n\nres23 = r.json().arrpop(\"riders\", \"$\")\nprint(res23)  # >>> ['\"Prickett\"']\n\nres24 = r.json().arrpop(\"riders\", \"$\")\nprint(res24)  # >>> [None]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex58",
      "language": "ruby",
      "code": "res16 = r.json_set('riders', '$', [])\nputs res16 # >>> OK\n\nres17 = r.json_arrappend('riders', '$', 'Norem')\np res17 # >>> [1]\n\nres18 = r.json_get('riders', '$')\np res18 # >>> [[\"Norem\"]]\n\nres19 = r.json_arrinsert('riders', '$', 1, 'Prickett', 'Royce', 'Castilla')\np res19 # >>> [4]\n\nres20 = r.json_get('riders', '$')\np res20 # >>> [[\"Norem\", \"Prickett\", \"Royce\", \"Castilla\"]]\n\nres21 = r.json_arrtrim('riders', '$', 1, 1)\np res21 # >>> [1]\n\nres22 = r.json_get('riders', '$')\np res22 # >>> [[\"Prickett\"]]\n\nres23 = r.json_arrpop('riders', '$')\np res23 # >>> [\"Prickett\"]\n\nres24 = r.json_arrpop('riders', '$')\np res24 # >>> [nil]\n\n# json_arrappend also takes a pre-encoded JSON value with raw: true.\nres_raw4 = r.json_arrappend('riders', '$', '\"Castilla\"', raw: true)\np res_raw4 # >>> [1]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex59",
      "language": "rust",
      "code": "let res17: bool = r\n            .json_set(\"riders\", \"$\", &json!([]))\n            .await\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res17); // >>> OK\n\n        let res18: Value = r\n            .json_arr_append(\"riders\", \"$\", &json!(\"Norem\"))\n            .await\n            .expect(\"Failed to run JSON.ARRAPPEND\");\n        print_redis_value(&res18); // >>> [1]\n\n        let res19: String = r\n            .json_get(\"riders\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res19}\"); // >>> [[\"Norem\"]]\n\n        let res20: Value = cmd(\"JSON.ARRINSERT\")\n            .arg(\"riders\")\n            .arg(\"$\")\n            .arg(1)\n            .arg(\"\\\"Prickett\\\"\")\n            .arg(\"\\\"Royce\\\"\")\n            .arg(\"\\\"Castilla\\\"\")\n            .query_async(&mut r)\n            .await\n            .expect(\"Failed to run JSON.ARRINSERT\");\n        print_redis_value(&res20); // >>> [4]\n\n        let res21: String = r\n            .json_get(\"riders\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res21}\"); // >>> [[\"Norem\",\"Prickett\",\"Royce\",\"Castilla\"]]\n\n        let res22: Value = r\n            .json_arr_trim(\"riders\", \"$\", 1, 1)\n            .await\n            .expect(\"Failed to run JSON.ARRTRIM\");\n        print_redis_value(&res22); // >>> [1]\n\n        let res23: String = r\n            .json_get(\"riders\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.GET\");\n        println!(\"{res23}\"); // >>> [[\"Prickett\"]]\n\n        let res24: Value = r\n            .json_arr_pop(\"riders\", \"$\", -1)\n            .await\n            .expect(\"Failed to run JSON.ARRPOP\");\n        print_redis_value(&res24); // >>> [\"Prickett\"]\n\n        let res25: Value = r\n            .json_arr_pop(\"riders\", \"$\", -1)\n            .await\n            .expect(\"Failed to run JSON.ARRPOP\");\n        print_redis_value(&res25); // >>> [null]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex60",
      "language": "rust",
      "code": "let res17: bool = r\n            .json_set(\"riders\", \"$\", &json!([]))\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res17); // >>> OK\n\n        let res18: Value = r\n            .json_arr_append(\"riders\", \"$\", &json!(\"Norem\"))\n            .expect(\"Failed to run JSON.ARRAPPEND\");\n        print_redis_value(&res18); // >>> [1]\n\n        let res19: String = r.json_get(\"riders\", \"$\").expect(\"Failed to run JSON.GET\");\n        println!(\"{res19}\"); // >>> [[\"Norem\"]]\n\n        let res20: Value = cmd(\"JSON.ARRINSERT\")\n            .arg(\"riders\")\n            .arg(\"$\")\n            .arg(1)\n            .arg(\"\\\"Prickett\\\"\")\n            .arg(\"\\\"Royce\\\"\")\n            .arg(\"\\\"Castilla\\\"\")\n            .query(&mut r)\n            .expect(\"Failed to run JSON.ARRINSERT\");\n        print_redis_value(&res20); // >>> [4]\n\n        let res21: String = r.json_get(\"riders\", \"$\").expect(\"Failed to run JSON.GET\");\n        println!(\"{res21}\"); // >>> [[\"Norem\",\"Prickett\",\"Royce\",\"Castilla\"]]\n\n        let res22: Value = r\n            .json_arr_trim(\"riders\", \"$\", 1, 1)\n            .expect(\"Failed to run JSON.ARRTRIM\");\n        print_redis_value(&res22); // >>> [1]\n\n        let res23: String = r.json_get(\"riders\", \"$\").expect(\"Failed to run JSON.GET\");\n        println!(\"{res23}\"); // >>> [[\"Prickett\"]]\n\n        let res24: Value = r\n            .json_arr_pop(\"riders\", \"$\", -1)\n            .expect(\"Failed to run JSON.ARRPOP\");\n        print_redis_value(&res24); // >>> [\"Prickett\"]\n\n        let res25: Value = r\n            .json_arr_pop(\"riders\", \"$\", -1)\n            .expect(\"Failed to run JSON.ARRPOP\");\n        print_redis_value(&res25); // >>> [null]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex61",
      "language": "plaintext",
      "code": "> JSON.SET bike:1 $ '{\"model\": \"Deimos\", \"brand\": \"Ergonom\", \"price\": 4972}'\nOK\n> JSON.OBJLEN bike:1 $\n1) (integer) 3\n> JSON.OBJKEYS bike:1 $\n1) 1) \"model\"\n   2) \"brand\"\n   3) \"price\"",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex62",
      "language": "csharp",
      "code": "bool res25 = db.JSON().Set(\"bike:1\", \"$\",\n            new { model = \"Deimos\", brand = \"Ergonom\", price = 4972 }\n        );\n        Console.WriteLine(res25);   // >>> True\n\n        long?[] res26 = db.JSON().ObjLen(\"bike:1\", \"$\");\n        Console.WriteLine(string.Join(\", \", res26));    // >>> 3\n\n        IEnumerable<HashSet<string>> res27 = db.JSON().ObjKeys(\"bike:1\", \"$\");\n        Console.WriteLine(\n            string.Join(\", \", res27.Select(b => $\"{string.Join(\", \", b.Select(c => $\"{c}\"))}\"))\n        ); // >>> model, brand, price",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex63",
      "language": "go",
      "code": "res25, err := rdb.JSONSet(ctx, \"bike:1\", \"$\",\n\t\tmap[string]interface{}{\n\t\t\t\"model\": \"Deimos\",\n\t\t\t\"brand\": \"Ergonom\",\n\t\t\t\"price\": 4972,\n\t\t},\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res25) // >>> OK\n\n\tres26, err := rdb.JSONObjLen(ctx, \"bike:1\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(*res26[0]) // >>> 3\n\n\tres27, err := rdb.JSONObjKeys(ctx, \"bike:1\", \"$\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res27) // >>> [brand model price]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex64",
      "language": "java",
      "code": "JsonObject bikeObj = parser.createJsonObject().put(\"model\", parser.createJsonValue(\"\\\"Deimos\\\"\"))\n                    .put(\"brand\", parser.createJsonValue(\"\\\"Ergonom\\\"\")).put(\"price\", parser.createJsonValue(\"\\\"4972\\\"\"));\n\n            CompletableFuture<Void> obj = asyncCommands.jsonSet(\"bike:1\", JsonPath.ROOT_PATH, bikeObj).thenCompose(r -> {\n                System.out.println(r); // >>> OK\n\n                return asyncCommands.jsonObjlen(\"bike:1\", JsonPath.ROOT_PATH);\n            }).thenCompose(res18 -> {\n                System.out.println(res18); // >>> [3]\n\n                return asyncCommands.jsonObjkeys(\"bike:1\", JsonPath.ROOT_PATH);\n            })\n                    .thenAccept(System.out::println)\n                    // >>> [model, brand, price]\n                    .toCompletableFuture();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex65",
      "language": "java",
      "code": "JsonObject bikeObj = parser.createJsonObject().put(\"model\", parser.createJsonValue(\"\\\"Deimos\\\"\"))\n                    .put(\"brand\", parser.createJsonValue(\"\\\"Ergonom\\\"\")).put(\"price\", parser.createJsonValue(\"\\\"4972\\\"\"));\n\n            Mono<Void> obj = reactiveCommands.jsonSet(\"bike:1\", JsonPath.ROOT_PATH, bikeObj).doOnNext(r -> {\n                System.out.println(r); // >>> OK\n            }).flatMap(r -> reactiveCommands.jsonObjlen(\"bike:1\", JsonPath.ROOT_PATH).collectList()).doOnNext(res18 -> {\n                System.out.println(res18); // >>> [3]\n            }).flatMap(res18 -> reactiveCommands.jsonObjkeys(\"bike:1\", JsonPath.ROOT_PATH).collectList())\n                    .doOnNext(System.out::println) // >>> [model, brand, price]\n                    .then();",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex66",
      "language": "java",
      "code": "String res25 = jedis.jsonSet(\"bike:1\", new Path2(\"$\"),\n            new JSONObject()\n                .put(\"model\", \"Deimos\")\n                .put(\"brand\", \"Ergonom\")\n                .put(\"price\", 4972)\n        );\n        System.out.println(res25);  // >>> OK\n\n        List<Long> res26 = jedis.jsonObjLen(\"bike:1\", new Path2(\"$\"));\n        System.out.println(res26);  // >>> [3]\n\n        List<List<String>> res27 = jedis.jsonObjKeys(\"bike:1\", new Path2(\"$\"));\n        System.out.println(res27);  // >>> [[price, model, brand]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex67",
      "language": "javascript",
      "code": "const res25 = await client.json.set(\n  \"bike:1\", \"$\", {\n    \"model\": \"Deimos\",\n    \"brand\": \"Ergonom\",\n    \"price\": 4972\n  }\n);\nconsole.log(res25); //  OK\n\nconst res26 = await client.json.objLen(\"bike:1\", { path: \"$\" });\nconsole.log(res26); //  [3]\n\nconst res27 = await client.json.objKeys(\"bike:1\", { path: \"$\" });\nconsole.log(res27); //  [['model', 'brand', 'price']]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex68",
      "language": "php",
      "code": "$bike1 = json_encode([\n            'model' => 'Deimos',\n            'brand' => 'Ergonom',\n            'price' => 4972,\n        ], JSON_THROW_ON_ERROR);\n        $res25 = $r->jsonset('bike:1', '$', $bike1);\n        echo $res25 . PHP_EOL;\n        // >>> OK\n\n        $res26 = $r->jsonobjlen('bike:1', '$');\n        echo json_encode($res26) . PHP_EOL;\n        // >>> [3]\n\n        $res27 = $r->jsonobjkeys('bike:1', '$');\n        echo json_encode($res27) . PHP_EOL;\n        // >>> [[\"model\",\"brand\",\"price\"]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex69",
      "language": "python",
      "code": "res25 = r.json().set(\n    \"bike:1\", \"$\", {\"model\": \"Deimos\", \"brand\": \"Ergonom\", \"price\": 4972}\n)\nprint(res25)  # >>> True\n\nres26 = r.json().objlen(\"bike:1\", \"$\")\nprint(res26)  # >>> [3]\n\nres27 = r.json().objkeys(\"bike:1\", \"$\")\nprint(res27)  # >>> [['model', 'brand', 'price']]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex70",
      "language": "ruby",
      "code": "res25 = r.json_set('bike:1', '$', { 'model' => 'Deimos', 'brand' => 'Ergonom', 'price' => 4972 })\nputs res25 # >>> OK\n\nres26 = r.json_objlen('bike:1', '$')\np res26 # >>> [3]\n\nres27 = r.json_objkeys('bike:1', '$')\np res27 # >>> [[\"model\", \"brand\", \"price\"]]\n\n# raw: true returns the object as unparsed JSON text.\nres_raw5 = r.json_get('bike:1', '$', raw: true)\nputs res_raw5 # >>> [{\"model\":\"Deimos\",\"brand\":\"Ergonom\",\"price\":4972}]  (a JSON string)",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex71",
      "language": "rust",
      "code": "let res26: bool = r\n            .json_set(\n                \"bike:1\",\n                \"$\",\n                &json!({\"model\": \"Deimos\", \"brand\": \"Ergonom\", \"price\": 4972}),\n            )\n            .await\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res26); // >>> OK\n\n        let res27: Value = r\n            .json_obj_len(\"bike:1\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.OBJLEN\");\n        print_redis_value(&res27); // >>> [3]\n\n        let res28: Value = r\n            .json_obj_keys(\"bike:1\", \"$\")\n            .await\n            .expect(\"Failed to run JSON.OBJKEYS\");\n        print_redis_value(&res28); // >>> [[\"brand\",\"model\",\"price\"]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "use-redis-with-json-ex72",
      "language": "rust",
      "code": "let res26: bool = r\n            .json_set(\n                \"bike:1\",\n                \"$\",\n                &json!({\"model\": \"Deimos\", \"brand\": \"Ergonom\", \"price\": 4972}),\n            )\n            .expect(\"Failed to run JSON.SET\");\n        print_set_result(res26); // >>> OK\n\n        let res27: Value = r\n            .json_obj_len(\"bike:1\", \"$\")\n            .expect(\"Failed to run JSON.OBJLEN\");\n        print_redis_value(&res27); // >>> [3]\n\n        let res28: Value = r\n            .json_obj_keys(\"bike:1\", \"$\")\n            .expect(\"Failed to run JSON.OBJKEYS\");\n        print_redis_value(&res28); // >>> [[\"brand\",\"model\",\"price\"]]",
      "section_id": "use-redis-with-json"
    },
    {
      "id": "format-cli-output-ex0",
      "language": "bash",
      "code": "$ redis-cli --raw\n> JSON.GET obj INDENT \"\\t\" NEWLINE \"\\n\" SPACE \" \" $\n[\n\t{\n\t\t\"name\": \"Leonard Cohen\",\n\t\t\"lastSeen\": 1478476800,\n\t\t\"loggedOut\": true\n\t}\n]",
      "section_id": "format-cli-output"
    }
  ]
}
