MessagePack
This article needs more citations. (June 2013) |
| MessagePack | |
|---|---|
| Internet media type | application/vnd.msgpack |
| Developed by | Sadayuki Furuhashi |
| Open format? | Yes |
| Website | Official website |
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 format specification defines encodings for integers, floating-point numbers, strings, binary data, arrays, maps, extension types and timestamp values.[1] The official implementation is available in a variety of languages such as C, C++, C#, D, Erlang, Go, Haskell, Java, JavaScript (NodeJS), Lua, OCaml, Perl, PHP, Python, Ruby, Rust, Scala, Smalltalk, and Swift.[2]
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
- bool, Boolean (
trueandfalse) - 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
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 strings. In JSON, map keys have to be strings, but MessagePack has 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 does not. 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 does not 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
- Apache Thrift
- Apache Avro
- BSON
- CBOR
- JSONB
- JSON
- Protocol Buffers
- Smile (data interchange format)
- UBJSON
- Comparison of data-serialization formats
- YAML
- External Data Representation (XDR)
References
- ^ "MessagePack specification". MessagePack. Retrieved 3 August 2026.
- ^ "Languages". Retrieved 4 Jan 2022.
External links
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.