7 ms·
I didn't know CBOR, but it looks similar to BSON and MessagePack, or is there a significant difference?
by pagnol 9y ago
I didn't know CBOR, but it looks similar to BSON and MessagePack, or is there a significant difference?
- heavenlyhash 9y agoRoughly that it isn't shit. I say that a bit tongue in cheek, but really: BSON has a monstrous amount of basic data types, some of which make very little sense and are very difficult to round-trip through other formats; and MessagePack had crippling basic sanity issues with what-are-bytes-vs-strings in its early history and that's something you simply can't recover from without declaring game over and making a new spec. CBOR has neither of these issues. It's almost completely isomorphic to json, plus supports byte arrays. It's very nice.
- roller 9y agoIn the feature category, I'd also mention direct support for unbounded collections. CBOR can be its own container format for streaming data.
- zbentley 9y agoDoes CBOR support lazy/partial deserialization? It's not a make-or-break feature, but the ability to pluck out individual fields from large MessagePack documents without deserializing the whole thing has been a significant performance/memory savings for me many times. I haven't played with flatbuffers, but it probably supports this as well, given its design. Are there other binary protocols that have first-class (i.e. present with a good API in the client libraries for all major languages) support for lazy/partial deserialization?
- js8 9y agoCBOR is very similar to MsgPack, so yes (if you design the schema well enough).
- ci5er 9y agoIs/Can CBOR be canonicalized (like ASN.1, for example) for the purpose of unambiguous generation and interpretation of hashes? EDIT: I am happy to see that it handles date-time. Not really my favorite part of the non-spec of JSON on that front...
- heavenlyhash 9y agoYou might be interested in IPLD in particular: https://ipld.io/ https://ipld.io/ They use CBOR as the underlying serialization, and have a deep interest in canonicalization and applications of hashing.
- RantyDave 9y agoMore cbor ranting... In Python you can replace json.loads/dumps with cbor.loads/dumps with no further changes. Going back again may prove to be an issue when you discover just how much it is that json can't do.