Live data from Hacker News

From XML to JSON to CBOR

cborbook.com

21–30 of 106 posts

Re: From XML to JSON to CBOR

#21

people are just straight up afraid to write their own binary formats, aren't they. it's not hard, it's exactly like creating your own text format but you write binary data instead of text, and you can't read it with your eyes right away (but you can after you've looked at enough of it.) there is nothing to fear or to even worry about; just try it. look up how things like TLV work on wikipedia. you can do just about a…

I assume you mean as an exercise? Not for actual use in any production system?

If you did mean for production use, I assume you also implement your own encryption, encoding schemes and everything else?

Re: From XML to JSON to CBOR

#22

Feels like a CBOR ad to me. I agree that most techs are familiar with XML and JSON, but calling CBOR a "pivotal data format" is a stretch compared to Protobuf, Parquet, Avro, Cap'n Proto, and many others: https://en.m.wikipedia.org/wiki/Comparison_of_data-serializa...

CBOR is just a standard data format. Why would it need an ad? What are they selling here?

Re: From XML to JSON to CBOR

#23

people are just straight up afraid to write their own binary formats, aren't they. it's not hard, it's exactly like creating your own text format but you write binary data instead of text, and you can't read it with your eyes right away (but you can after you've looked at enough of it.) there is nothing to fear or to even worry about; just try it. look up how things like TLV work on wikipedia. you can do just about a…

CBOR has some stuff that is nice but would be annoying to reimplement. Like using more bytes to store large numbers than small ones. If you need a quick multipurpose binary format, CBOR is pretty good. The only alternative I’d make manually is just memcpy the bytes of a C struct directly to disk and hope that I won’t encounter a system with different endianness.

Re: From XML to JSON to CBOR

#26
CBOR is when you need option for very small code size. If you can always use compression, CBOR provides no significant data size improvement over JSON.

With small code size it beats also BSON, EBML and others.

Re: From XML to JSON to CBOR

#28
I wish browsers would support CBOR natively so I could just return CBOR instead of JSON(++speed --size ==win) and not have to be concerned with decoding it or not being able to debug requests in dev console.

Re: From XML to JSON to CBOR

#30
post #27

Earlier quoted context omitted.

CBOR isn't a hobby spec. It's integral to the WebAuthn API spec. Every time someone uses a passkey, CBOR is used to exchange messages with the authenticator

why was CBOR used for WebAuthn and was that a good idea?

Because given the same input data structure every correct implementation generates exactly the same byte sequence, so it's useful for signing. This isn't true of many other data formats, including JSON and protocol buffers.
Post reply on HN