# keyval/resp-stringify
Encode a Deft value as a RESP reply frame — the other half of
`keyval/resp-parse`, for building server facades.
## Syntax
[keyval/resp-stringify $value ?proto]
## Parameters
- `$value` — the value to encode
- `$proto` — `2` or `3` (default `3`); any other number is an `%Err`
Encoding (RESP3 / RESP2): strings and keywords → bulk string; integral
numbers → `:` integer; floats → `,` double / bulk string; booleans →
`#t`/`#f` / `:1`/`:0`; `nil` → `_` / `$-1`; vectors → array; sets → `~` /
array; maps → `%` / flat array; `%Err{:message}` → `-error` line (both
protocols). Map keys must be scalars and are written as bulk strings.
## Examples
[keyval/resp-stringify "hi"] # → "$2\r\nhi\r\n" [keyval/resp-stringify 42] # → ":42\r\n" [keyval/resp-stringify 3.5] # → ",3.5\r\n" [keyval/resp-stringify true] # → "#t\r\n" [keyval/resp-stringify %{ :k "v" }] # → "%1\r\n$1\r\nk\r\n$1\r\nv\r\n" [keyval/resp-stringify [err "boom"]] # → "-boom\r\n" [keyval/resp-stringify nil 2] # → "$-1\r\n"
## Returns
Encoded string; `%Err{:message}` for an unsupported value, an invalid
`proto`, or a `%Err` without a string `:message` (`"ERR"` is substituted
when one is missing).
## See Also
`keyval/resp-parse`, `keyval/cmd`