Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (34 sloc) 1.24 KB


This is a Clojure wrapper for the MessagePack library.

It allows you serialize and deserialize simple clojure objects to and from a well-defined binary format that is portable to many other programming languages.


Put some objects in a file:

(require '[clj-msgpack.core :as mp])
(use '[ :only [output-stream]])

(def data [nil true false {"yo" "dawg"} ["foo" "bar"]])
(with-open [f (output-stream "./temp.dat")]
  (mp/pack-into f "Hello" 23)
  (apply mp/pack-into f data))

Pull them back out somewhere else (eg: ruby):

require 'msgpack'
u =
u.feed('./temp.dat') )
u.each {|ob| p ob}
  ["foo", "bar"]


Why would you want to use this instead of, say, JSON, or Java serialization? Honestly, I'm not sure yet :) The serialization format is portable to many languages, and it's quite compact, especially if you are serializing a lot of numbers. For stringy data, it's probably not much smaller than JSON. At some point I'll do some benchmarks to see how small and/or fast this is compared to some of the alternatives.