# (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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.lisppad.app/libraries/lispkit/lispkit-serialize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
