> For the complete documentation index, see [llms.txt](https://www.lisppad.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.lisppad.app/libraries/lispkit/lispkit-serialize.md).

# (lispkit serialize)

Library `(lispkit serialize)` provides a simple API for serializing and deserializing Scheme expressions. With procedure `serialize`, Scheme expressions are serialized into binary data represented as bytevectors. Such bytevectors can be deserialized back into their original value with procedure `deserialize`.

Only the following types of expressions can be serialized:

* Booleans
* Numbers
* Characters
* Strings
* Symbols
* Bytevectors
* Lists
* Vectors
* Hashtables
* Bitsets
* Date-time values
* JSON values

**(serializable?&#x20;*****expr*****)**     <img src="/files/STqjiJsrexexyFklGQwH" alt="" data-size="line">

Returns `#t` if *expr* is an expression which can be serialized via procedure `serialize` into a bytevector. `serializable?` returns `#f` otherwise.

**(deserializable?&#x20;*****bvec*****)**     <img src="/files/STqjiJsrexexyFklGQwH" alt="" data-size="line">\
\&#xNAN;**(deserializable?&#x20;*****bvec start*****)**\
\&#xNAN;**(deserializable?&#x20;*****bvec start end*****)**

Returns `#t` if bytevector *bvec* between *start* and *end* can be deserialized into a valid Scheme expression via procedure `deserialize`. Otherwise, `deserializable?` returns `#f`.

**(serialize&#x20;*****expr*****)**     <img src="/files/STqjiJsrexexyFklGQwH" alt="" data-size="line">\
\&#xNAN;**(serialize&#x20;*****expr default*****)**

Serializes expression *expr* into a binary representation returned in form of a bytevector. Only the following types of expressions can be serialized: booleans, numbers, characters, strings, symbols, bytevectors, lists, vectors, hashtables, bitsets, date-time and JSON values. If *default* is not provided, `serialize` raises an error whenever a value that cannot be serialized is encountered. If *default* is provided and is serializable, then *default* is serialized instead of each value that is not serializable.

**(deserialize&#x20;*****bvec*****)**     <img src="/files/STqjiJsrexexyFklGQwH" alt="" data-size="line">\
\&#xNAN;**(deserialize&#x20;*****bvec start*****)**\
\&#xNAN;**(deserialize&#x20;*****bvec start end*****)**

Deserializes a bytevector *bvec* between *start* and *end* into a Scheme expression. `deserialize` raises an error if the bytevector cannot be deserialized successfully.
