(pack value)(pack value opts)Pack the given value into a msgpack byte-array.
Accepts an optional opts map containing:
:key-fn - A function accepting the key of a map being packed. Can be
used to efficiently cast map keys to new types. Defaults to the
stringify-keys-mapper fn.:extensions - A vector of custom msgpack data type extensions that
will be used to pack non-standard datatypes.Example:
(pack {:a 1} {:key-fn stringify-keys-mapper})
(pack [1 2 3])
Pack the given `value` into a msgpack byte-array.
Accepts an optional `opts` map containing:
- **`:key-fn`** - A function accepting the key of a map being packed. Can be
used to efficiently cast map keys to new types. Defaults to the
[[stringify-keys-mapper]] fn.
- **`:extensions`** - A vector of custom msgpack data type extensions that
will be used to pack non-standard datatypes.
Example:
```clojure
(pack {:a 1} {:key-fn stringify-keys-mapper})
(pack [1 2 3])
```(pack-stream stream value)(pack-stream stream value opts)Like pack but writes the packed bytes directly into a given stream.
Like [[pack]] but writes the packed bytes directly into a given `stream`.
(unpack resource)(unpack resource opts)Unpack a msgpack value from a given resource.
The resource can be any one of:
Accepts an optional opts map containing:
:key-fn - A function accepting the key of a map being unpacked. Can
be used to efficiently cast map keys to new types.:extensions - A vector of custom msgpack data type extensions that
will be used to unpack non-standard datatypes.Example:
(unpack (pack {:a 1})) ;; => {"a" 1}
(unpack (pack {:a 1}) {:key-fn keywordize-keys-mapper}) ;; => {:a 1}
(unpack (io/input-stream (pack 1))) ;; => 1
Unpack a msgpack value from a given `resource`.
The `resource` can be any one of:
- A byte-array
- A type implementing [[java.io.InputStream]]
Accepts an optional `opts` map containing:
- **`:key-fn`** - A function accepting the key of a map being unpacked. Can
be used to efficiently cast map keys to new types.
- **`:extensions`** - A vector of custom msgpack data type extensions that
will be used to unpack non-standard datatypes.
Example:
```clojure
(unpack (pack {:a 1})) ;; => {"a" 1}
(unpack (pack {:a 1}) {:key-fn keywordize-keys-mapper}) ;; => {:a 1}
(unpack (io/input-stream (pack 1))) ;; => 1
```cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |