Map
RESP3prefix: % · client type: dict / HashMap / Map<K,V> / object
RESP3 maps encode key-value dictionaries natively. Format: %<count>\r\n followed by count×2 elements (alternating keys and values). HGETALL, CONFIG GET, and XAUTOCLAIM now return maps instead of flat alternating arrays. Clients can return native dict/HashMap/object without knowing the command name.
Details
Maps have the format %<count>\r\n followed by count×2 RESP elements (key, value, key, value...).
The count is the number of key-value pairs, not individual elements. A map with 2 pairs has count=2 and 4 total elements.
Keys and values can be any RESP3 type. In practice Redis typically uses simple strings or bulk strings as map keys.
Example – HGETALL in RESP2 vs RESP3: RESP2: *4\r\n+field1\r\n+val1\r\n+field2\r\n+val2\r\n (flat array, client must know it's a hash) RESP3: %2\r\n+field1\r\n+val1\r\n+field2\r\n+val2\r\n (map, client knows it's a dict)
In RESP3, CONFIG GET also returns a map instead of a flat array.
Nested maps are possible: a map value can itself be a map, set, or array.
Wire encoding
%2\r\n+field1\r\n+value1\r\n+field2\r\n+value2\r\n
# represents {field1: value1, field2: value2}Type information
| Prefix byte | % |
| Version | RESP3 |
| Client type | dict / HashMap / Map<K,V> / object |
| Specification | RESP3 specification (GitHub) → |