CBOR
≈ 5 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
Concise Binary Object Representation (CBOR) is a binary data serialization format loosely based on JSON authored by Carsten Bormann and Paul Hoffman. Like JSON it allows the transmission of data objects that contain name–value pairs, but in a more concise manner. This increases processing and transfer speeds at the cost of human readability. It is defined in IETF . Amongst other uses, it is the recommended data serialization layer for the CoAP Internet of Things protocol suite and the data format on which COSE messages are based. It is also used in the Client-to-Authenticator Protocol (CTAP) within the scope of the FIDO2 project. CBOR was inspired by MessagePack, which was developed and promoted by Sadayuki Furuhashi. CBOR extended MessagePack, particularly by allowing to distinguish text strings from byte strings, which was implemented in 2013 in MessagePack.
Concise Binary Object Representation (CBOR) is a binary data serialization format loosely based on JSON authored by Carsten Bormann and Paul Hoffman. Like JSON it allows the transmission of data objects that contain name–value pairs, but in a more concise manner. This increases processing and transfer speeds at the cost of human readability. It is defined in IETF . Amongst other uses, it is the recommended data serialization layer for the CoAP Internet of Things protocol suite and the data format on which COSE messages are based. It is also used in the Client-to-Authenticator Protocol (CTAP) within the scope of the FIDO2 project. CBOR was inspired by MessagePack, which was developed and promoted by Sadayuki Furuhashi. CBOR extended MessagePack, particularly by allowing to distinguish text strings from byte strings, which was implemented in 2013 in MessagePack. [{"x": 1, "yz": true}, [2, "w" --> 82 # array(2) A2 # map(2) 61 # text(1) 78 # "x" 01 # unsigned(1) 62 # text(2) 797A # "yz" F5 # primitive(21) 82 # array(2) 02 # unsigned(2) 61 # text(1) 77 # "w" Note: While the JSON representation requires 27 characters – the 5 spaces can be omitted – the same data is encoded in only 13 octets of CBOR. A short count of 31 is used with non-atomic types 2–5 to indicate an indefinite length; the payload is the following items until a "break" marker byte of 255 (type=7, short count=31). A short count of 31 is not permitted with the other atomic types 0, 1 or 6. Type 6 (tag) is unusual in that its count field encodes a value directly, but also has a payload field (which always consists of a single item). Extended counts, and all multi-byte values, are encoded in network (big-endian) byte order. The DAG-CBOR specification is a stricter subset of CBOR, developed by Protocol Labs. The problem that DAG-CBOR solves is that, in CBOR, an object can be serialized in more than one way. For example, {"b":1,"a":2} can be represented as either A2 # map(2) 61 # text(1) 62 # "b" 01 # unsigned(1) 61 # text(1) 61 # "a" 02 # unsigned(2) or A2 # map(2) 61 # text(1) 61 # "a" 02 # unsigned(2) 61 # text(1) 62 # "b" 01 # unsigned(1) This means that one object can have two different serializations. The DAG-CBOR specification uniquely picks a single CBOR representation, out of all possible CBOR representations of an object. Some objects that can have a CBOR representation no longer has a DAG-CBOR representation, because their nature does not allow for a unique representation. For example, an indefinite-length item (can be a string, byte sequence, list, and map) does not have a DAG-CBOR representation, even though it can have a CBOR representation. The DAG-CBOR specification allows consistent content-addressable storage. Specifically, a piece of data can be uniquely serialized as a sequence of bytes, and this sequence can then be hashed as its CID (content ID), usable for content-addressing. The name "DAG" denotes "directed acyclic graph", since the specification was produced specifically to allow for data objects in the form of Merkle DAGs.
Notes
References
External links
Online tool to convert from CBOR binary to textual representation and back. CBOR Zone: Online tool to convert a CBOR item or a CBOR sequence in the format of HEX, Base64, Base64URL or CBOR Diagnostic Notation into another format.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1375259767 under CC BY-SA 4.0; modifications have been made.