Array
RESP2prefix: * · client type: List / Array / []
Arrays contain an ordered sequence of other RESP types. Format: *<count>\r\n followed by count elements. Arrays can be nested. *-1\r\n is a null array. Used for multi-value replies: LRANGE list elements, KEYS, HMGET values. In RESP3, SMEMBERS returns a ~ set and HGETALL returns a % map instead of flat arrays.
Details
Arrays have the format *<count>\r\n followed by count RESP elements. Elements can be any type including nested arrays.
Null array: *-1\r\n is a null array (used by some commands, equivalent to null bulk). In RESP3, null (_) replaces both null bulk and null array.
Empty array: *0\r\n is an empty array.
Nested arrays: arrays of arrays are used for commands like EXEC (returns array of command results) and XREAD (nested stream entries).
The RESP2 limitation: LRANGE, SMEMBERS, and HGETALL all return *-arrays, so clients must know per-command whether to interpret the result as a list, set, or dictionary. RESP3 fixes this with typed set (~) and map (%) replies.
In RESP2, commands that should return a set (SMEMBERS, SDIFF, SUNION) return an array, and commands that should return a dictionary (HGETALL, CONFIG GET) return a flat alternating key-value array.
Wire encoding
*3\r\n:1\r\n:2\r\n:3\r\n # [1, 2, 3] *-1\r\n # null array *2\r\n*2\r\n:1\r\n:2\r\n*2\r\n:3\r\n:4\r\n # [[1,2],[3,4]]
Type information
| Prefix byte | * |
| Version | RESP2 |
| Client type | List / Array / [] |
| Specification | RESP3 specification (GitHub) → |