Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Binary serialization of Clojure objects using MessagePack.
Branch: master
Pull request Compare This branch is 2 commits behind grammati:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/clj_msgpack
test/clj_msgpack/test
.gitignore
LICENSE
README.md
project.clj

README.md

clj-msgpack

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.

Example

Put some objects in a file:

(require '[clj-msgpack.core :as mp])
(use '[clojure.java.io :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 = MessagePack::Unpacker.new
u.feed( File.read('./temp.dat') )
u.each {|ob| p ob}
  "Hello"
  23
  nil
  true
  false
  {"yo"=>"dawg"}
  ["foo", "bar"]

Why?

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.

Something went wrong with that request. Please try again.