(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.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. 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.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. 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 is a website building & hosting documentation for Clojure/Script libraries
× close