-
Notifications
You must be signed in to change notification settings - Fork 59
What is CBOR? And why choose CBOR?
CBOR is a concise binary data format inspired by JSON and MessagePack. CBOR is defined in RFC 8949 (December 2020) which obsoletes RFC 7049 (October 2013).
CBOR is an Internet Standard by IETF. It's used in other standards like WebAuthn by W3C, COSE (RFC 8152), CWT (RFC 8392), CDDL (RFC 8610) and more.
It depends on your requirements and priorities. Reasons for using CBOR include:
-
CBOR is an IETF Internet Standard designed to be relevant for decades without breaking changes.
-
CBOR is designed to offer extensibility without the need for version negotiation.
-
Data is self-describing and avoids problems caused by generated code (or schemas) being out of sync with data.
-
Data is smaller and more efficient to process than JSON. And CBOR's generic data model is a superset of JSON's.
-
Using CBOR can reduce time spent maintaining large systems, especially when used with Go struct tags like
toarray
andkeyasint
provided by fxamacker/cbor.
Given these reasons, some projects replaced JSON with CBOR. Or migrated from gRPC+protobuf to gRPC+CBOR.