Module MessagePack
In: ext/pack.c
ext/unpack.c
ext/rbinit.c
ext/version.rb

MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.

You can install MessagePack with rubygems.

  gem install msgpack

Simple usage is as follows:

  require 'msgpack'
  msg = [1,2,3].to_msgpack  #=> "\x93\x01\x02\x03"
  MessagePack.unpack(msg)   #=> [1,2,3]

Use Unpacker class for streaming deserialization.

Methods

pack   unpack   unpack_limit  

Classes and Modules

Class MessagePack::UnpackError
Class MessagePack::Unpacker

Constants

VERSION = rb_str_new2(MESSAGEPACK_VERSION)
VERSION = "0.4.7"

Public Class methods

Document-method: MessagePack.pack

Serializes the object into raw bytes. The encoding of the string is ASCII-8BIT on Ruby 1.9. This method is same as object.to_msgpack(out = ’’).

out is an object that implements *<<* method like String or IO.

Document-method: MessagePack::Unpacker.unpack

Deserializes one object over the specified buffer.

UnpackError is throw when parse error is occured, the buffer is insufficient to deserialize one object or there are extra bytes.

Document-method: MessagePack::Unpacker.unpack_limit

Deserializes one object over the specified buffer upto limit bytes.

UnpackError is throw when parse error is occured, the buffer is insufficient to deserialize one object or there are extra bytes.

[Validate]