Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

MessagePack

From Wikipedia, the free encyclopedia
Digital data interchange format
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "MessagePack" – news ·newspapers ·books ·scholar ·JSTOR
(June 2013) (Learn how and when to remove this message)
MessagePack
Internet media typeapplication/vnd.msgpack
Developed bySadayuki Furuhashi
Open format?Yes
WebsiteOfficial websiteEdit this at Wikidata
MessagePack
Original author(s)Sadayuki Furuhashi
Repository
Written inVarious languages
Operating systemAny
PlatformCross-platform
TypeData interchange
LicenseBoost Software License
Websitemsgpack.org

MessagePack is acomputer data interchange format. It is a binary form for representing simpledata structures likearrays andassociative arrays. MessagePack aims to be as compact and simple as possible. The official implementation is available in a variety of languages, some official libraries and others community created, such asC,C++,C#,D,Erlang,Go,Haskell,Java,JavaScript (NodeJS),Lua,OCaml,Perl,PHP,Python,Ruby,Rust,Scala,Smalltalk, andSwift.[1]

Data types and syntax

[edit]

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

  • nil
  • bool,Boolean (true andfalse)
  • int,integer (up to 64 bits signed or unsigned)
  • float, floating point numbers (IEEE single/double precision)
  • str,UTF-8string
  • bin, binary data (up to 232 − 1 bytes)
  • array
  • map, anassociative array
  • ext (arbitrary data of an application-defined format, up to 232 − 1 bytes)
  • timestamp (ext type = −1) (up to 64-bit seconds and 32-bit nanoseconds)

Comparison to other formats

[edit]

MessagePack is more compact thanJSON, but imposes limitations on array and integer sizes. On the other hand, it allows binary data and non-UTF-8 encoded strings. In JSON, map keys have to be strings, but in MessagePack there is no such limitation and any type can be a map key, including types like maps and arrays, and, likeYAML, numbers.

Compared toBSON, MessagePack is more space-efficient. BSON is designed for fast in-memory manipulation, whereas MessagePack is designed for efficient transmission over the wire. For example, BSON requires null terminators at the end of all strings and inserts string indexes for list elements, while MessagePack doesn't. BSON represents both arrays and maps internally as documents, which are maps, where an array is a map with keys as decimal strings counting up from 0. MessagePack on the other hand represents both maps and arrays as arrays, where each map key-value pair is contiguous, making odd items keys and even items values.

TheProtocol Buffers format provides a significantly more compact transmission format than MessagePack because it doesn't transmit field names. However, while JSON and MessagePack aim to serialize arbitrary data structures with type tags, Protocol Buffers requires a schema to define the data types. Protocol Buffers compiler createsboilerplate code in the target language to facilitate integration of serialization into the application code; MessagePack returns only adynamically typed data structure and provides no automatic structure checks.

MessagePack is referenced inRFC 7049 ofCBOR.

See also

[edit]

References

[edit]
  1. ^"Languages". Retrieved4 Jan 2022.

External links

[edit]
Human readable
Binary
Retrieved from "https://en.wikipedia.org/w/index.php?title=MessagePack&oldid=1256072570"
Category:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp