redis-cli: Add OUTPUT_JSON format type (#9954)
Introduce `redis-cli --json` option. CSV doesn't support Map type, then parsing SLOWLOG or HMSET with multiple args are not helpful. By default the `--json` implies RESP3, which makes it much more useful, and a `-2` option was added to force RESP2. When `HELLO 3` fails, it prints a warning message (which can be silenced with `-2`). If a user passed `-3` explicitly, the non-interactive mode will also exit with error without running the command, while in interactive session it'll keep running after printing the warning. JSON output would be helpful to parse Redis replies with other tools like jq. ``` redis-cli --json slowlog get | jq [ [ 1, 1639677545, 322362, [ "HMSET", "dummy-key", "field1", "123,456,789... (152 more bytes)", "field2", "111,222,333... (140 more bytes)", "field3", "... (349 more arguments)" ], "127.0.0.1:49312", "" ] ] ```
Please register or sign in to comment