Live data from Hacker News

From XML to JSON to CBOR

cborbook.com

101–106 of 106 posts

Re: From XML to JSON to CBOR

#101
post #81

Earlier quoted context omitted.

The ASN.1 notation wasn't meant for parsing. And then people started writing parsing generators for it, so they adapted. However, you're abusing a text format for human reading and pretending it's a serialization format. The BER/PER are binary formats and great where binary formats are needed. You also have XER (XML) and JER (JSON) if you want text. You can create an s-expr encoding if you want. Separate ASN.1--the d…

> However, you're abusing a text format for human reading and pretending it's a serialization format. They should be the same, in order to facilitate human debugging. And we were discussing ASN.1, not its serialisations. Frankly, I thought that it was fairer to compare the S-expression to ASN.1, because both are human-readable, rather than to an opaque blob like: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrEee0Ri4Juz+Qfi…

> And we were discussing ASN.1, not its serialisations.

You said

>> Would you rather write a parser for this:

which suggested you were talking about serializations. I apologize if I misunderstood.

Re: From XML to JSON to CBOR

#102

Erlang / Elixir has amazing support for ASN.1! I love it. https://www.erlang.org/doc/apps/asn1/asn1_getting_started.ht... https://www2.erlang.org/documentation/doc-14/lib/asn1-5.1/do... ( https://www2.erlang.org/documentation/doc-14/lib/asn1-5.1/do... ) I am using ASN.1 to communicate between a client (Java / Kotlin) and server (Erlang / Elixir), but unfortunately Java / Kotlin has somewhat of a shitty support for AS…

I also use ASN.1 but I use C, so I wrote my own implementation of DER.

Does it support constraints?

Re: From XML to JSON to CBOR

#103
post #81

Earlier quoted context omitted.

> However, you're abusing a text format for human reading and pretending it's a serialization format. They should be the same, in order to facilitate human debugging. And we were discussing ASN.1, not its serialisations. Frankly, I thought that it was fairer to compare the S-expression to ASN.1, because both are human-readable, rather than to an opaque blob like: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrEee0Ri4Juz+Qfi…

> And we were discussing ASN.1, not its serialisations. You said >> Would you rather write a parser for this: which suggested you were talking about serializations. I apologize if I misunderstood.

No worries! ASN.1 is a bit weird because there’s a textual version and then a bunch of serialisations.

I think that human-readable is more important than space-efficient. At some point an engineer is going to be looking at bytes in a dump or debugger, and it sure is nice to be able to quickly know what they are.

Re: From XML to JSON to CBOR

#104

Earlier quoted context omitted.

I also use ASN.1 but I use C, so I wrote my own implementation of DER.

Does it support constraints?

It is a C library, and does not implement ASN.1 schema at all, only implements reading/writing the data. The caller is expected to implement most constraints that would be required, although you can limit the size of data being read, and the functions for decoding integers will automatically check that the type is correct (although you can disable type checking) and will limit the values to those that fit in the variable that the decoded value is stored in (e.g. signed 64-bits, unsigned 8-bits, etc), and other functions that decode specific values will also normally check the type (although you can tell it to not check the type).

Re: From XML to JSON to CBOR

#105
post #62

Earlier quoted context omitted.

i write my own binary formats because they're fast and small. yes, in production. partly because it's just as easy as anything else for me now, partly because it doesn't require any dependencies at all, and partly to show others just how easy it is, because i think people are unnecessarily afraid of this. no i don't write my own encoding or encryption. why the hell would anyone use json for everything, and why would…

I didn't say anywhere that we should use json for everything. I think most people would go with something standard and documented. If you work in a team it helps if you can hire people that are familiar with tech or can read up on it easily. And in general, unless you can show that your formatter is an actual hot path in need of optimization, you've just added another piece of code in need of care and feeding for no…

> Also I would never want to be on the same team

100% agree with you.

Re: From XML to JSON to CBOR

#106

Earlier quoted context omitted.

Does it support constraints?

It is a C library, and does not implement ASN.1 schema at all, only implements reading/writing the data. The caller is expected to implement most constraints that would be required, although you can limit the size of data being read, and the functions for decoding integers will automatically check that the type is correct (although you can disable type checking) and will limit the values to those that fit in the vari…

Do you know of any C library that is similar to Erlang's ASN.1?
Post reply on HN