Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

407 lines (361 sloc) 20.155 kB
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="MessagePack, msgpack, JSON, Binary JSON, Serializer, Serialization" />
<!--<meta name="description" content="" />-->
<link href='favicon.ico' rel='icon' type='image/x-icon'/>
<title>MessagePack: It's like JSON. but fast and small.</title>
<!--[if lt IE 9]><script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js" ></script><![endif]-->
<link media="all" rel="stylesheet" type="text/css" href="css/yuibase.css" />
<link media="all" rel="stylesheet" type="text/css" href="js/prettify/prettify.css" />
<link media="all" rel="stylesheet" type="text/css" href="css/all.css" />
<script type="text/javascript" src="js/all.js" ></script>
<script type="text/javascript" src="js/prettify/prettify.js" ></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17125377-1']);
_gaq.push(['_setDomainName', 'msgpack.org']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body onload="prettyPrint();changeQuickStart('qs-ruby',document.getElementById('quickstart-default'));">
<!-- Facebook like button { -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- } Facebook like button -->
<header id="header">
<div id="headerwrap">
<h1 id="logo"><a href="/">MessagePack</a></h1>
<nav id="topnav">
<ul>
<li><a href="https://github.com/msgpack">GitHub</a></li>
<li><a href="http://wiki.msgpack.org/display/MSGPACK/Home">Wiki</a></li>
<li><a href="http://twitter.com/search/MessagePack%20OR%20msgpack">#msgpack</a></li>
<li><a href="http://wiki.msgpack.org/display/MSGPACK/Format+specification">Spec</a></li>
</ul>
</nav>
</div>
</header>
<div id="desc">
<div id="descbody">
<img id="descimg" width="421" height="251" src="images/msgpack-json.png"/>
<div id="desctext">
<h2>It's like JSON. but fast and small.</h2>
<p>MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON but it's faster and smaller. For example, small integers (like flags or error code) are encoded into a single byte, and typical short strings only require an extra byte in addition to the strings themselves.</p>
<p>If you ever wished to use JSON for convenience (storing an image with metadata) but could not for technical reasons (encoding, size, speed...), MessagePack is a perfect replacement.</p>
<pre>&gt; require "msgpack" # gem install msgpack
&gt; msg = [1,2,3].to_msgpack #=&gt; "\x93\x01\x02\x03"
&gt; MessagePack.unpack(msg) #=&gt; [1,2,3]</pre>
<p>...and <a href="#crosslang">many other languages</a></p>
</div>
</div>
</div>
<div id="background">
<div id="content">
<h3>Happy Hackers :-)</h3>
<div class="tmset">
<a class="tmleft"></a>
<div class="tm">
<a class="tmlogo" href="http://redis.io/"><img src="images/redis.png" alt="Redis" width="150" height="50" /></a>
<p class="tmtext">"Redis scripting has support for MessagePack because it is a fast and compact serialization format with a simple to implement specification. I liked it so much that I implemented a MessagePack C extension for Lua just to include it into Redis."</p>
<p class="tmauthor">Salvatore Sanfilippo, creator of Redis.</p>
</div>
<div class="tm">
<a class="tmlogo" href="http://pinterest.com/"><img src="images/pinterest.png" alt="Pinterest" width="197" height="50" /></a>
<p class="tmtext">"MessagePack has been simply invaluable to us. We use MessagePack + Memcache to cache many of our feeds on Pinterest. These feeds are compressed and very quick to unpack thanks to MessagePack while Memcache gives us fast atomic pushes."</p>
<p class="tmauthor">Marty Weiner, Software Engineer.</p>
</div>
<div class="tm">
<a class="tmlogo" href="http://saltstack.com/"><img src="images/saltstack.png" alt="Salt Stack" width="251" height="46" /></a>
<p class="tmtext">"I use MessagePack for all of the data serialization in Salt, it is fantastic! I tested quite a few serialization formats and MessagePack was dramatically faster and the data was always smaller. When I changed out pickles for MessagePack in Salt there was a speed increase of almost 3 fold across the board."</p>
<p class="tmauthor">Tom Hatch, author of Salt.</p>
</div>
<a class="tmright"></a>
</div>
<p class="tmcontribute">Also use MessagePack? <a href="https://github.com/msgpack/website">Waiting for your testimonial!</a></p>
<h3 id="crosslang">Implementation projects</h3>
<div class="qsset">
<ul class="qslist">
<li><a onclick="changeQuickStart('qs-ruby',this)" id="quickstart-default">Ruby</a></li>
<li><a onclick="changeQuickStart('qs-python',this)">Python</a></li>
<li><a onclick="changeQuickStart('qs-perl',this)">Perl</a></li>
<li><a onclick="changeQuickStart('qs-cpp',this)">C/C++</a></li>
<li><a onclick="changeQuickStart('qs-java',this)">Java</a></li>
<li><a onclick="changeQuickStart('qs-php',this)">PHP</a></li>
<li><a onclick="changeQuickStart('qs-javascript',this)">JavaScript</a></li>
<li><a onclick="changeQuickStart('qs-objective-c',this)">Objective-C</a></li>
<li><a onclick="changeQuickStart('qs-csharp',this)">C#</a></li>
<li><a onclick="changeQuickStart('qs-lua',this)">Lua</a></li>
<li><a onclick="changeQuickStart('qs-scala',this)">Scala</a></li>
<li><a onclick="changeQuickStart('qs-d',this)">D</a></li>
<li><a onclick="changeQuickStart('qs-haskell',this)">Haskell</a></li>
<li><a onclick="changeQuickStart('qs-erlang',this)">Erlang</a></li>
<li><a onclick="changeQuickStart('qs-ocaml',this)">OCaml</a></li>
<li><a onclick="changeQuickStart('qs-smalltalk',this)">Smalltalk</a></li>
<li><a onclick="changeQuickStart('qs-go',this)">Go</a></li>
<li><a onclick="changeQuickStart('qs-labview',this)">LabVIEW</a></li>
</ul>
<div id="quickstart" class="qsholder"></div>
<div id="qs-ruby" class="qs">
<h4>Ruby</h4>
<ul class="hlist">
<li><a href="http://msgpack.org/rdoc/current/MessagePack.html">API Reference</a></li>
<li><a href="http://rubygems.org/gems/msgpack">RubyGems</a></li>
</ul>
<pre class="prettyprint">gem install msgpack</pre>
<pre class="prettyprint">require "msgpack"
msg = [1,2,3].to_msgpack #=&gt; "\x93\x01\x02\x03"
MessagePack.unpack(msg) #=&gt; [1,2,3]</pre>
<p>Ruby implementation provides <a href="http://msgpack.org/rdoc/current/MessagePack/Unpacker.html">streaming deserializer</a>.</p>
</div>
<div id="qs-python" class="qs">
<h4>Python</h4>
<ul class="hlist">
<li><a href="http://pypi.python.org/pypi/msgpack-python/">PyPI</a></li>
</ul>
<pre class="prettyprint">easy_install msgpack-python</pre>
<pre class="prettyprint">import msgpack
msg = msgpack.packb([1,2,3]) #=&gt; "\x93\x01\x02\x03"
msgpack.unpackb(msg) #=&gt; [1,2,3]
help(msgpack)</pre>
<p>Python implementation provides streaming deserializer.</p>
</div>
<div id="qs-perl" class="qs">
<h4>Perl</h4>
<ul class="hlist">
<li><a href="http://search.cpan.org/~tokuhirom/Data-MessagePack/lib/Data/MessagePack.pm">API Reference</a></li>
<li><a href="http://search.cpan.org/~tokuhirom/Data-MessagePack/">CPAN</a></li>
</ul>
<pre class="prettyprint">cpan Data::MessagePack</pre>
<pre class="prettyprint">use Data::MessagePack;
my $packed = Data::MessagePack-&gt;pack($dat);
my $unpacked = Data::MessagePack-&gt;unpack($dat);</pre>
<p>Perl implementation provides <a href="http://search.cpan.org/~typester/Data-MessagePack-Stream/lib/Data/MessagePack/Stream.pm">streaming deserializer</a>.</p>
</div>
<div id="qs-cpp" class="qs">
<h4>C/C++</h4>
<ul class="hlist">
<li><a href="https://github.com/msgpack/msgpack-c">GitHub</a></li>
<li><a href="http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+C+Language">Quick Start for C</a></li>
<li><a href="http://wiki.msgpack.org/pages/viewpage.action?pageId=1081387">Quick Start for C++</a></li>
</ul>
<pre class="prettyprint">port install msgpack # MacPorts
brew install msgpack # Homebrew
apt-get install libmsgpack-dev # Ubuntu</pre>
<p>Or download <a href="http://msgpack.org/releases/cpp/msgpack-0.5.7.tar.gz">msgpack-0.5.7.tar.gz</a> and build it to install.</p>
<pre class="prettyprint">#include &lt;msgpack.hpp&gt;
struct myclass { std::vector<int> vec; MSGPACK_DEFINE(vec); };
msgpack::pack(buffer, vec);
msgpack::unpack(&amp;result, buffer.data(), buffer.size());</pre>
</div>
<div id="qs-java" class="qs">
<h4>Java</h4>
<ul class="hlist">
<li><a href="http://msgpack.org/javadoc/current/">API Reference</a></li>
<li><a href="http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.msgpack%22%20AND%20a%3A%22msgpack%22">Maven</a></li>
<li><a href="https://github.com/msgpack/msgpack-java">GitHub</a></li>
</ul>
<pre class="prettyprint">import org.msgpack.MessagePack;
MessagePack msgpack = new MessagePack();
byte[] bytes = msgpack.write(object);
MyClass object = msgpack.read(bytes, MyClass.class);</pre>
<p>Java implementation provides <a href="http://msgpack.org/javadoc/current/org/msgpack/unpacker/package-summary.html">streaming deserializer</a>, <a href="http://msgpack.org/javadoc/current/org/msgpack/type/package-summary.html">dynamically typed objects</a>, <a href="http://msgpack.org/javadoc/current/org/msgpack/template/package-summary.html">type conversion templates</a>, <a href="http://msgpack.org/javadoc/current/org/msgpack/template/builder/package-summary.html">dynamic template generators</a> and <a href="http://msgpack.org/javadoc/current/org/msgpack/annotation/package-summary.html">annotations</a>.</p>
<p>Take a look at <a href="https://github.com/msgpack/msgpack-java/tree/master/src/test/java/org/msgpack">test cases</a> for examples.</p>
</div>
<div id="qs-php" class="qs">
<h4>PHP</h4>
<ul class="hlist">
<li><a href="http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+PHP">Quick Start</a></li>
</ul>
<pre class="prettyprint">git clone https://github.com/msgpack/msgpack.git
cd msgpack/php
phpize
./configure &amp;&amp; make &amp;&amp; make install</pre>
<pre class="prettyprint">$data = array(0=&gt;1,1=&gt;2,2=&gt;3);
$msg = msgpack_pack($data);
$data = msgpack_unpack($msg);</pre>
</div>
<div id="qs-javascript" class="qs">
<h4>JavaScript</h4>
<ul class="hlist">
<li><a href="https://github.com/msgpack/msgpack-javascript">GitHub</a></li>
<li><a href="https://raw.github.com/msgpack/msgpack-javascript/master/msgpack.js">msgpack.js</a></li>
</ul>
<pre class="prettyprint">var myByteArray = msgpack.pack(myObject);
myObject = msgpack.unpack(myByteArray);</pre>
<p>Licensed under MIT license.</p>
</div>
<div id="qs-objective-c" class="qs">
<h4>Objective-C</h4>
<ul class="hlist">
<li><a href="https://github.com/msgpack/msgpack-objectivec">GitHub</a></li>
</ul>
<pre class="prettyprint">
#import "MessagePack.h"
..
NSData* packed = [someArray messagePack];
NSArray* someArray = [packed messagePackParse];
</pre>
</div>
<div id="qs-csharp" class="qs">
<h4>C#</h4>
<ul class="hlist">
<li><a href="https://github.com/msgpack/msgpack-cli">GitHub</a></li>
<li><a href="https://github.com/yfakariya/msgpack/wiki/">Wiki</a></li>
</ul>
<pre class="prettyprint">using MsgPack.Serialization;</pre>
<pre class="prettyprint">var serializer = MessagePackSerializer.Create&lt;Foo&gt;();
serializer.Pack(foo, stream);
stream.Position = 0;
var value = serializer.Unpack(stream);</pre>
<p>You can also use C#(CLI) implementation for any other CLI (Common Language Infrastructure) languages such as Visual Basic.<br />
CLI implementation also provides streaming deserializer, some level of dynamic typing, and annotations. See <a href="https://github.com/yfakariya/msgpack/wiki/">Wiki</a> for details.</p>
</div>
<div id="qs-lua" class="qs">
<h4>Lua</h4>
Coming soon...
<!--
<ul class="hlist">
<li><a href="https://github.com/nobu-k/mplua">GitHub</a></li>
</ul>
<pre class="prettyprint">require "msgpack"
data = msgpack.pack(1, 2, 3, "strings", {"a", "r", "r", "a", "y", "s"},
{t = "a", b = "l", e = "s"; 1, 2, 3, 4})
a, b, c = msgpack.unpack(msgpack.pack(1, 2, 3))</pre>
-->
</div>
<div id="qs-scala" class="qs">
<h4>Scala</h4>
<ul class="hlist">
<li><a href="http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+Scala">Quick Start</a></li>
</ul>
</div>
<div id="qs-d" class="qs">
<h4>D</h4>
<ul class="hlist">
<li><a href="http://msgpack.org/ddoc/">API Reference</a></li>
<li><a href="https://github.com/msgpack/msgpack-d">GitHub</a></li>
</ul>
<p>msgpack-d is only one file. Please add msgpack.d to your project.</p>
<pre class="prettyprint">import msgpack;
Tuple!(uint, string) receive, send = tuple(2012. "Hello D!");
auto serialized = pack(send);
unpack(serialized, receive);
assert(send == recieve);</pre>
<p>D implementation also provides streaming deserializer.</p>
</div>
<div id="qs-haskell" class="qs">
<h4>Haskell</h4>
<ul class="hlist">
<li><a href="http://hackage.haskell.org/packages/archive/msgpack/0.7.1.5/doc/html/Data-MessagePack.html">API Reference</a></li>
<li><a href="http://hackage.haskell.org/package/msgpack">hackageDB</a></li>
<li><a href="http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+Haskell">Quick Start</a></li>
</ul>
<pre class="prettyprint">import Data.MessagePack
main = do
let bs = pack (1 :: Int, 3.14 :: Double, "Hello, MessagePack!")
print bs
print (unpack bs :: (Int, Double, String))
</pre>
</div>
<div id="qs-erlang" class="qs">
<h4>Erlang</h4>
<ul class="hlist">
<li><a href="http://msgpack.org/edoc/">API Reference</a></li>
<li><a href="http://github.com/msgpack/msgpack-erlang">Repository</a></li>
</ul>
<p>Write into your <a href="http://github.com/basho/rebar">rebar</a>.config:</p>
<pre class="prettyprint">{deps, [
{msgpack, ".*",
{git, "git://github.com/msgpack/msgpack-erlang.git", "HEAD"}}
]}.</pre>
<pre class="prettyprint">{Spam, _} = msgpack:pack(Ham),
Ham = msgpack:unpack(Spam).</pre>
</div>
<div id="qs-ocaml" class="qs">
<h4>OCaml</h4>
<pre class="prettyprint">
$ git clone git@github.com:msgpack/msgpack-ocaml.git
$ cd msgpack-ocaml
$ omake
$ omake install</pre>
<pre class="prettyprint">
Msgpack.Serialize.desrialize_string("\147\001\002\003");;
</pre>
<a href="https://github.com/msgpack/msgpack-ocaml/tree/master/proof">This library is mathematically proven!</a>
</div>
<div id="qs-smalltalk" class="qs">
<h4>Smalltalk</h4>
<ul class="hlist">
<li><a href="https://github.com/msgpack/msgpack-smalltalk">GitHub</a></li>
</ul>
<pre class="prettyprint">
map := Dictionary new.
map at: 'someArray' asByteArray put: #(1 2.2 #[3 4 5]).
packed := map messagePacked.
(Object fromMessagePack: packed) inspect.
</pre>
</div>
<div id="qs-go" class="qs">
<h4>Go</h4>
Coming soon...
</div>
<div id="qs-labview" class="qs">
<h4>LabVIEW</h4>
<ul class="hlist">
<li><a href="http://msgpack-labview.sf.net">SourceForge</a></li>
</ul>
Installable through the VI Package Manager using one of the compiled versions on the
<a href="https://sourceforge.net/projects/msgpack-labview/files/">downloads page</a>
</div>
</div>
<h3>Related projects</h3>
<div class="paragraphs">
<h4><a href="https://github.com/dotcloud/zerorpc-python">ZeroRPC</a> by DotCloud</h4>
<p>zerorpc is a flexible RPC implementation based on zeromq and messagepack. Service APIs exposed with zerorpc are called "zeroservices".</p>
<h4><a href="https://github.com/pfi/pficommon">pficommon</a> by Preferred Infrastructure, Inc.</h4>
<p>General purpose C++ library for Preferred Infrastructure, Inc. It includes MessagePack-RPC implementation for C++</p>
<!--
<h4><a href="http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+Ruby#QuickStartforRuby-RPCQuickStartforRuby">MessagePack-RPC for Ruby</a></h4>
<p>MessagePack-RPC implementation for Ruby</p>
<h4><a href="http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+Java#QuickStartforJava-MessagePackRPCforJava">MessagePack-RPC for Java</a></h4>
<p>MessagePack-RPC implementation for Java</p>
<h4><a href="https://github.com/msgpack/msgpack-rpc/tree/master/haskell">MessagePack-RPC for Haskell</a></h4>
<p>MessagePack-RPC implementation for Haskell</p>
<h4><a href="https://github.com/msgpack/msgpack-rpc-python">MessagePack-RPC for Python</a></h4>
<p>MessagePack-RPC implementation for Python</p>
-->
</div>
</div>
</div>
<footer id="footer">
<div id="footerbody" class="paragraphs">
<div id="social">
<!--
<iframe src="http://markdotto.github.com/github-buttons/github-btn.html?user=msgpack&type=follow"
allowtransparency="true" frameborder="0" scrolling="0" width="132px" height="20px"></iframe>
-->
<a href="https://twitter.com/share" class="twitter-share-button" data-hashtags="msgpack">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<div class="fb-like" data-href="http://msgpack.org/" data-send="false" data-layout="button_count" data-width="120" data-show-faces="false"></div>
</div>
<div id="thanks">
<p id="sponsor"><a href="http://treasure-data.com/?source=mp">Sponsored by Treasure Data, Inc. <img src="images/td-icon.png" width="20" height="20" /></a></p>
<p>Copyright &copy; 2008-2012 FURUHASHI Sadayuki</p>
</div>
</div>
</footer>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.