CBOR
Concise Binary Object Representation is a binary data serialization format loosely based on JSON. 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 within the scope of the FIDO2 project.
Specification of the CBOR encoding
CBOR encoded data is seen as a stream of data items. E.g.Major type and additional type handling in each data item
Each data item behaviour is defined by the major type and additional type.The major type is used for selecting the main behaviour or type of each data item.
The additional type is additional information whose exact behaviour is dependent on the major type value.
CBOR data item field encoding
Tiny Field Encoding
Short Field Encoding
Long Field Encoding
CBOR data item header
The table below illustrates how the CBOR data item header works.- Byte = 8 bits
Primitives (Major type = 7)
Break control code (Additional type value = 31)
This is a meta value, that is used in conjunction with arrays and maps set to indefinite length mode. This indicates to the CBOR parser to close the corresponding map or array level.IEEE 754 Floats (Additional type value = 25 or 26 or 27)
This allows for storing floats, encoded as IEEE 754 float values.Simple value
Most simple values are either unassigned or reserved for future improvements.However these are defined.
Simple value | Semantic |
20 | Boolean false |
21 | Boolean true |
22 | Null |
23 | Undefined |
Semantic Tag Registration
IANA has created the CBOR tags registry, located in https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml. Registration must contain these template.https://tools.ietf.org/html/rfc7049#section-7.2
Implementations
Name | Primary author | Language | License | Source | Remarks |
cbor-js | Patrick Gansterer | JavaScript | MIT | https://github.com/paroga/cbor-js | |
node-cbor | Joe Hildebrand | JavaScript | MIT | https://github.com/hildjj/node-cbor | |
CBOREncode | Pavel Gulbin | PHP | PHP | https://github.com/2tvenom/CBOREncode | |
cbor | Faye Amacker | Go | MIT | https://github.com/fxamacker/cbor | Safe & fast, CBOR tags, float64/32/16, duplicate map key detection, API is encoding/json + toarray & keyasint struct tags, Canonical CBOR, CTAP2, fuzz tested. |
cbor | Pavel Gulbin | Go | WTFPL | https://github.com/2tvenom/cbor | |
cbor_go | Brian Olson | Go | APL 2.0 | https://github.com/brianolson/cbor_go | |
go-codec | Ugorji Nwoke | Go | MIT | https://godoc.org/github.com/ugorji/go/codec | Also handles JSON, MsgPack and BinC. |
serde_cbor | Pyfisch | Rust | MIT or APL 2.0 | https://github.com/pyfisch/cbor | |
cbor-codec | Toralf Wittner | Rust | MPL 2.0 | https://twittner.gitlab.io/cbor-codec/cbor/ | |
SwiftCBOR | greg@unrelenting.technology | Swift | Unlicense | https://github.com/myfreeweb/SwiftCBOR | |
CBOR.jl | Saurav Sachidanand | Julia | MIT | https://github.com/saurvs/CBOR.jl | |
Lua-CBOR | Kim Alvefur | Lua | MIT | https://www.zash.se/lua-cbor.html | |
org.conman.cbor | Sean Conner | Lua | LGPL-3 | https://github.com/spc476/CBOR | |
cbor_py | Brian Olson | Python | APL 2.0 | https://github.com/brianolson/cbor_py | |
flynn | Fritz Conrad Grimpen | Python | MIT | https://github.com/fritz0705/flynn | |
cbor2 | Alex Grönholm | Python | MIT | https://github.com/agronholm/cbor2 | |
CBOR::Free | Felipe Gasper | Perl | Artistic & GPL | https://metacpan.org/pod/CBOR::Free | - |
CBOR::PP | Felipe Gasper | Perl | Artistic & GPL | https://metacpan.org/pod/CBOR::PP | |
CBOR::XS | Marc Lehmann | Perl | GPL-3 | https://metacpan.org/pod/CBOR::XS | |
cbor-ruby | Sadayuki Furuhashi Carsten Bormann | Ruby | APL 2.0 | https://github.com/cabo/cbor-ruby | |
libcbor-ruby | Pavel Kalvoda | Ruby | MIT | https://github.com/PJK/libcbor-ruby | Binding to libcbor. |
cbor-erlang | Jihyun Yu | Erlang | BSD-3-clause | https://github.com/yjh0502/cbor-erlang | |
excbor | Carsten Bormann | Elixir | not specified, ask the author | https://github.com/cabo/excbor | |
CBOR | R. Kyle Murphy | Haskell | LGPL-3 | https://github.com/orclev/CBOR | |
borc | Joe Hildebrand Friedel Ziegelmayer | JavaScript | MIT | https://github.com/dignifiedquire/borc | Fork of node-cbor. |
borc-refs | Joe Hildebrand Friedel Ziegelmayer Sandro Hawke | JavaScript | MIT | https://github.com/sandhawke/borc-refs | Fork of borc. |
CBOR | Peter Occil | C# | Public domain software | https://github.com/peteroupc/CBOR | Also handles JSON. |
Dahomey.Cbor | Michaël Catanzariti | C# | MIT License | https://github.com/dahomey-technologies/Dahomey.Cbor | |
Jackson | Tatu Saloranta | Java | APL-2.0 | https://github.com/FasterXML/jackson-dataformats-binary/tree/master/cbor | Also handles other formats. |
cbor-java | Constantin Rack | Java | APL-2.0 | https://github.com/c-rack/cbor-java | |
jacob | J.W. Janssen | Java | APL-2.0 | https://github.com/jawi/jacob | |
kotlinx.serialization | JetBrains | Kotlin | APL-2.0 | https://github.com/Kotlin/kotlinx.serialization | Supports cross-platform |
cn-cbor | Joe Hildebrand Carsten Bormann | C | MIT | https://github.com/cabo/cn-cbor | |
cbor-cpp | Stanislav Ovsyannikov | C++ | APL-2.0 | https://github.com/naphaso/cbor-cpp | |
cppbor | David Preece | C++ | BSD | https://github.com/rantydave/cppbor | Uses C++17 variants. |
libcbor | Pavel Kalvoda | C | MIT | https://github.com/PJK/libcbor | |
tinycbor | Intel | C | MIT | https://github.com/01org/tinycbor | |
cbor-d | Andrey Penechko | D | Boost 1.0 | https://github.com/MrSmith33/cbor-d | |
clj-cbor | Greg Look | Clojure | Unlicense | https://github.com/greglook/clj-cbor | |
JSON for Modern C++ | Niels Lohmann | C++ | MIT | https://github.com/nlohmann/json | Also handles JSON and MsgPack. |
borabora | Christoph Engelbert | Java | APL-2.0 | https://github.com/noctarius/borabora | |
lua-ConciseSerialization | François Perrad | Lua | MIT | https://web.archive.org/web/20170322112326/https://fperrad.github.io/lua-ConciseSerialization/ | |
flunn | Fritz Conrad Grimpen Sokolov Yura | Python | MIT | https://pypi.python.org/pypi/flunn | |
cbor-qt | Anton Dutov | C++ | Public domain | https://github.com/anton-dutov/cbor-qt | - |
QCborValue | Qt Project | C++ | LGPL | https://doc.qt.io/qt-5/qcborvalue.html | Part of the Qt framework since version 5.12 |
cbor11 | Jakob Varmose Bentzen | C++ | Public domain | https://github.com/jakobvarmose/cbor11 | |
cborcpp | Alex Nekipelov | C++ | MIT | https://github.com/nekipelov/cborcpp | |
GoldFish | Vincent Lascaux | C++ | MIT | https://github.com/OneNoteDev/GoldFish | |
Library-Arduino-Cbor | Juanjo Tara | C++ | APL-2.0 | https://github.com/jjtara/Library-Arduino-Cbor | |
cborg | Duncan Coutts | Haskell | BSD-3-clause | https://github.com/well-typed/cborg | |
cbor | Steve Hamblett | Dart | MIT | https://github.com/shamblett/cbor | |
borer | Mathias Doenitz | Scala | MPL 2.0 | https://github.com/sirthias/borer | Also handles JSON. |