• Yuta Hongo's avatar
    redis-cli: Better --json Unicode support and --quoted-json (#10286) · e3ef73dc
    Yuta Hongo authored
    Normally, `redis-cli` escapes non-printable data received from Redis, using a custom scheme (which is also used to handle quoted input). When using `--json` this is not desired as it is not compatible with RFC 7159, which specifies JSON strings are assumed to be Unicode and how they should be escaped.
    
    This commit changes `--json` to follow RFC 7159, which means that properly encoded Unicode strings in Redis will result with a valid Unicode JSON.
    
    However, this introduces a new problem with `--json` and data that is not valid Unicode (e.g., random binary data, text that follows other encoding, etc.). To address this, we add `--quoted-json` which produces JSON strings that follow the original redis-cli quoting scheme.
    
    For example, a value that consists of only null (0x00) bytes will show up as:
    * `"\u0000\u0000\u0000"` when using `--json`
    * `"\\x00\\x00\\x00"` when using `--quoted-json`
    e3ef73dc
redis-cli.tcl 16 KB