Jump to content

MessagePack: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Adding local short description: "Digital data interchange format", overriding Wikidata description "data serialization format"
 
(29 intermediate revisions by 26 users not shown)
Line 1: Line 1:
{{Short description|Digital data interchange format}}
{{multiple issues|
{{Notability|Products|date=March 2012}}
{{Refimprove|date=June 2013}}
{{Refimprove|date=June 2013}}
{{Infobox file format
| name = MessagePack
| icon =
| iconcaption =
| icon_size =
| screenshot =
| screenshot_size =
| caption =
|_noextcode =
| extension = <!-- or: | extensions = -->
| developer = Sadayuki Furuhashi
| released = <!-- {{start date and age|YYYY|mm|dd|df=yes/no}} -->
| latest_release_version =
| latest_release_date = <!-- {{start date and age|YYYY|mm|dd|df=yes/no}} -->
| type =
| standard = <!-- or: | standards = -->
| free =
| open = Yes
| url = {{Official website}}
}}
}}
{{Infobox software
{{Infobox software
| name = MessagePack
| name = MessagePack
| author = Sadayuki Furuhashi
| author = Sadayuki Furuhashi
| genre = Data interchange
| genre = Data interchange
| license = [[Apache License]]
| license = [[Boost Software License]]
| programming language = Various languages
| programming language = Various languages
| operating_system = Any
| operating_system = Any
| platform = [[Cross-platform]]
| platform = [[Cross-platform]]
| website = {{URL|//msgpack.org/}}
| status = Active
| latest_release_version = 0.5.7
| website = {{URL|http://msgpack.org/}}
}}
}}


'''MessagePack''' is a [[computer]] data interchange format. It is a binary form for representing simple [[data structure]]s like [[Array data structure|arrays]] and [[associative array]]s. MessagePack aims to be as compact and simple as possible. The official implementation is available in a variety of languages such as [[C (programming language)|C]], [[C++]], [[C Sharp (programming language)|C#]], [[D (programming language)|D]], [[Erlang (programming language)|Erlang]], [[Go (programming language)|Go]], [[Haskell (programming language)|Haskell]], [[Java (programming language)|Java]], [[JavaScript]], [[Lua (programming language)|Lua]], [[OCaml]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[Scala (programming language)|Scala]], [[Smalltalk]], and [[Swift (programming language)|Swift]].<ref>{{cite web |url=http://msgpack.org/#crosslang |title=Implementation Projects |accessdate=28 May 2013 }}</ref>
'''MessagePack''' is a [[computer]] data interchange format. It is a binary form for representing simple [[data structure]]s like [[Array data structure|arrays]] and [[associative array]]s. 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 as [[C (programming language)|C]], [[C++]], [[C Sharp (programming language)|C#]], [[D (programming language)|D]], [[Erlang (programming language)|Erlang]], [[Go (programming language)|Go]], [[Haskell (programming language)|Haskell]], [[Java (programming language)|Java]], [[JavaScript]] ([[NodeJS]]), [[Lua (programming language)|Lua]], [[OCaml]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[Rust (programming language)|Rust]], [[Scala (programming language)|Scala]], [[Smalltalk]], and [[Swift (programming language)|Swift]].<ref>{{cite web |url=https://msgpack.org/index.html#languages |title=Languages|accessdate=4 Jan 2022 }}</ref>


==Data types and syntax==
==Data types and syntax==
Data structures processed by MessagePack loosely correspond to those used in [[JSON]] format. They consist of the following element types:
Data structures processed by MessagePack loosely correspond to those used in [[JSON]] format. They consist of the following element types:
*nil
* nil
*bool, [[boolean datatype|boolean]] (<code>true</code> and <code>false</code>)
* bool, [[Boolean data type|Boolean]] (<code>true</code> and <code>false</code>)
*int, [[Integer_(computer_science)|integer]] (up to 64 bits signed or unsigned)
* int, [[Integer_(computer_science)|integer]] (up to 64 bits signed or unsigned)
*float, floating point numbers (IEEE single/double precision)
* float, floating point numbers (IEEE single/double precision)
*str, [[UTF-8]] [[String_(computer_science)|string]]
* str, [[UTF-8]] [[String_(computer_science)|string]]
*bin, binary data (up to 2<sup>32</sup>-1 bytes)
* bin, binary data (up to 2<sup>32</sup> − 1 bytes)
*[[Array data structure|array]]
* [[Array data structure|array]]
*map, an [[associative array]]
* map, an [[associative array]]
*ext (arbitrary data of an application-defined format, up to 2<sup>32</sup>-1 bytes)
* ext (arbitrary data of an application-defined format, up to 2<sup>32</sup> − 1 bytes)
* timestamp (ext type = −1) (up to 64-bit seconds and 32-bit nanoseconds)


==Comparison to other formats==
==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. 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, like YAML, numbers.
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. 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, like [[YAML]], numbers.


Compared to [[BSON]], 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.
Compared to [[BSON]], 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.


The [[Protocol Buffers]] format aims to be compact and is on par with MessagePack. However, while JSON and MessagePack aim to serialize arbitrary data structures with type tags, Protocol Buffers require a schema to define the data types. Protocol Buffers compiler creates [[boilerplate code]] in target language to facilitate integration of serialization into the application code; MessagePack returns only [[dynamic typing|dynamically-typed]] data structure and provides no automatic structure checks.
The [[Protocol 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 creates [[boilerplate code]] in the target language to facilitate integration of serialization into the application code; MessagePack returns only a [[dynamic typing|dynamically typed]] data structure and provides no automatic structure checks.

MessagePack is referenced in {{IETF RFC|7049}} of [[CBOR]].


==See also==
==See also==
Line 41: Line 60:
*[[Apache Avro]]
*[[Apache Avro]]
*[[BSON]]
*[[BSON]]
*[[CBOR]]
*[[PostgreSQL#Data types|JSONB]]
*[[JSON]]
*[[JSON]]
*[[Protocol Buffers]]
*[[Protocol Buffers]]
*[[Smile (Data Interchange Format)|Smile]]
*[[Smile (data interchange format)|Smile]]
*[[UBJSON]]
*[[UBJSON]]
*[[Comparison of data serialization formats]]
*[[Comparison of data serialization formats]]
*[[YAML]]
*[[External Data Representation|XDR]]


==References==
==References==

Latest revision as of 01:46, 8 November 2024

MessagePack
Internet media typeapplication/vnd.msgpack
Developed bySadayuki Furuhashi
Open format?Yes
WebsiteOfficial website Edit 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 a computer data interchange format. It is a binary form for representing simple data structures 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, some official libraries and others community created, such as C, C++, C#, D, Erlang, Go, Haskell, Java, JavaScript (NodeJS), Lua, OCaml, Perl, PHP, Python, Ruby, Rust, Scala, Smalltalk, and Swift.[1]

Data types and syntax

[edit]

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

  • nil
  • bool, Boolean (true and false)
  • int, integer (up to 64 bits signed or unsigned)
  • float, floating point numbers (IEEE single/double precision)
  • str, UTF-8 string
  • bin, binary data (up to 232 − 1 bytes)
  • array
  • map, an associative 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 than JSON, 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, like YAML, numbers.

Compared to BSON, 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.

The Protocol 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 creates boilerplate code in the target language to facilitate integration of serialization into the application code; MessagePack returns only a dynamically typed data structure and provides no automatic structure checks.

MessagePack is referenced in RFC 7049 of CBOR.

See also

[edit]

References

[edit]
  1. ^ "Languages". Retrieved 4 Jan 2022.
[edit]