Happy Hackers :-)
"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."
"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."
"Fluentd uses MessagePack for all internal data representation. It's crazy fast because of zero-copy optimization of msgpack-ruby. Now MessagePack is an essential component of Fluentd to achieve high performance and flexibility at the same time."
"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."
Also use MessagePack? Waiting for your testimonial!
Implementation projects
- Ruby
- Python
- Perl
- C/C++
- Java
- Scala
- PHP
- Lua
- JavaScript
- Node.js
- Haskell
- C#
- Objective-C
- Erlang
- D
- OCaml
- Go
- LabVIEW
- Smalltalk
Ruby
gem install msgpack
require "msgpack" msg = [1,2,3].to_msgpack #=> "\x93\x01\x02\x03" MessagePack.unpack(msg) #=> [1,2,3]
Ruby implementation provides streaming deserializer.
Python
easy_install msgpack-python
import msgpack msg = msgpack.packb([1,2,3]) #=> "\x93\x01\x02\x03" msgpack.unpackb(msg) #=> [1,2,3] help(msgpack)
Python implementation provides streaming deserializer.
Perl
cpan Data::MessagePack
use Data::MessagePack; my $packed = Data::MessagePack->pack($dat); my $unpacked = Data::MessagePack->unpack($dat);
Perl implementation provides streaming deserializer.
C/C++
port install msgpack # MacPorts brew install msgpack # Homebrew apt-get install libmsgpack-dev # Ubuntu
Or download msgpack-0.5.7.tar.gz and build it to install.
#include <msgpack.hpp>
struct myclass { std::vector vec; MSGPACK_DEFINE(vec); };
msgpack::pack(buffer, vec);
msgpack::unpack(&result, buffer.data(), buffer.size());
Java
import org.msgpack.MessagePack; MessagePack msgpack = new MessagePack(); byte[] bytes = msgpack.write(object); MyClass object = msgpack.read(bytes, MyClass.class);
Java implementation provides streaming deserializer, dynamically typed objects, type conversion templates, dynamic template generators and annotations.
Take a look at test cases for examples.
PHP
git clone https://github.com/msgpack/msgpack-php.git cd msgpack-php phpize ./configure && make && make install
$data = array(0=>1,1=>2,2=>3); $msg = msgpack_pack($data); $data = msgpack_unpack($msg);
Node.js
npm install msgpack
var msgpack = require('msgpack');
var o = {"a" : 1, "b" : 2, "c" : [1, 2, 3]};
var b = msgpack.pack(o);
var oo = msgpack.unpack(b);
JavaScript
var myByteArray = msgpack.pack(myObject); myObject = msgpack.unpack(myByteArray);
Licensed under MIT license.
Objective-C
#import "MessagePack.h"
..
NSData* packed = [someArray messagePack];
NSArray* someArray = [packed messagePackParse];
C#
using MsgPack.Serialization;
var serializer = MessagePackSerializer.Create<Foo>(); serializer.Pack(foo, stream); stream.Position = 0; var value = serializer.Unpack(stream);
You can also use C#(CLI) implementation for any other CLI (Common Language Infrastructure) languages such as Visual Basic.
CLI implementation also provides streaming deserializer, some level of dynamic typing, and annotations. See Wiki for details.
Lua
Coming soon...Scala
D
msgpack-d is only one file. Please add msgpack.d to your project.
import msgpack; Tuple!(uint, string) receive, send = tuple(2012. "Hello D!"); auto serialized = pack(send); unpack(serialized, receive); assert(send == recieve);
D implementation also provides streaming deserializer.
Haskell
import Data.MessagePack main = do let bs = pack (1 :: Int, 3.14 :: Double, "Hello, MessagePack!") print bs print (unpack bs :: (Int, Double, String))
Erlang
Write into your rebar.config:
{deps, [
{msgpack, ".*",
{git, "git://github.com/msgpack/msgpack-erlang.git", "HEAD"}}
]}.
Binary = msgpack:pack(Spam),
{ok, Spam} = msgpack:unpack(Binary).
OCaml
$ opam install msgpack
type t = { ans : int } with conv(msgpack)
let bytes =
Msgpack.Serialize.serialize_string (msgpack_of_t { ans = 42 })
let { ans = n } =
t_of_msgpack (Msgpack.Serialize.deserialize_string bytes)
This library is mathematically proven!
Smalltalk
map := Dictionary new.
map at: 'someArray' asByteArray put: #(1 2.2 #[3 4 5]).
packed := map messagePacked.
(Object fromMessagePack: packed) inspect.
Go
Coming soon...LabVIEW
Installable through the VI Package Manager using one of the compiled versions on the downloads pageRelated projects
ZeroRPC by DotCloud
zerorpc is a flexible RPC implementation based on zeromq and messagepack. Service APIs exposed with zerorpc are called "zeroservices".
pficommon by Preferred Infrastructure, Inc.
General purpose C++ library for Preferred Infrastructure, Inc. It includes MessagePack-RPC implementation for C++