Jump to content

MessagePack

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Overload7 (talk | contribs) at 12:06, 24 February 2013 (Null is wrong, Nil is correct .). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
MessagePack
Original author(s)Sadayuki Furuhashi
Stable release
0.5.7
Repository
Written inVarious languages
Operating systemAny
PlatformCross-platform
TypeData interchange
LicenseApache License
Websitemsgpack.org

MessagePack is a computer data interchange format. It is a binary form for representing simple data structure like arrays and associative arrays. MessagePack aims to be as compact and simple as possible. The official implementation is available in a variety of languages such as C, C++, C#, D, Erlang, Go, Haskell, Java, JavaScript, Lua, OCaml, Perl, PHP, Python, Ruby, Scala and Smalltalk.

Data types and syntax

Data structures processed by MessagePack loosely correspond to those used in JSON format. They consist of the following element types:

  • nil
  • boolean (true and false)
  • integer (up to 64 bits signed or unsigned)
  • floating point numbers (IEEE single/double precision)
  • byte array (string or binary data)
  • list ("array")
  • associative array ("map")

Comparison to other formats

MessagePack is more compact than JSON, but imposes limitations on array and integer sizes. On the other hand, it allows binary data and non UTF-8 encoded strings.

Compared to BSON, MessagePack is more space-efficient. For example, BSON requires zero-byte terminators at the end of all strings and inserts string indexes for list elements, while MessagePack doesn't. Also, MessagePack allows more compact representation of small integers and short lists and associative arrays.

Protocol buffers format aims to be compact and is on par with MessagePack. However, while JSON and MessagePack aim to serialize arbitrary data structures, Protocol buffers is strongly typed and requires a schema which defines data types that compose the structure. Protocol buffers compiler creates boilerplate code in target language to facilitate integration of serialization into the application code; MessagePack returns only dynamically-typed data structure and provides no automatic structure checks.

See also