News for hackers. Stuff that matters.
Re:JSON with Commas and Comments by bawolff on Tuesday February 23, 2021 @03:44AM (#26235124)
I think JSON demonstrates that most of the time you don't need it, and doing that sort of thing badly is worse than not doing it at all.

E.g. XML has all that, and yet the average use of xml is much more fragile thsn the average use of json. Similarly asn.1 has all that, but does anyone actually like the fact the x509 certs use it? (To be clear, json would definitely not be appropriate for that case either).

Re:JSON with Commas and Comments by vidarh on Tuesday February 23, 2021 @03:51AM (#26235168)
There are both JSON [1] and XML [2] encoding rules specified for ASN.1... I have never seen it used in the wild, but realising it's a thing is horrifying enough.

[1] https://www.itu.int/rec/T-REC-X.697/en

[2] https://www.itu.int/rec/T-REC-X.693/en

Re:JSON with Commas and Comments by nly on Tuesday February 23, 2021 @04:06AM (#26235241)
I've used BER encoded ASN.1 at work quite a bit, and the reason you won't see it much are pretty much:

- HORRIBLE schema format.

- Very few FOSS libraries, most of which are terrible. I used Lev Walkins asn1c[0], which I patched slightly and coupled with some semi-generic code that walks the generated data structures to emit JSON (for debugging purposes).

[0] https://github.com/vlm/asn1c

Re:JSON with Commas and Comments by johnisgood on Tuesday February 23, 2021 @05:32AM (#26235711)
Erlang's ASN.1 is awesome! Have a look at http://erlang.org/doc/apps/asn1/asn1.pdf! It could even be used as an introductory reading to ASN.1, to be honest.
Re:JSON with Commas and Comments by vidarh on Tuesday February 23, 2021 @04:57AM (#26235534)
I've implemented (a subset of) ASN.1 for an SNMP server I wrote for an embedded monitoring system, so I know the pain, but it was one thing to implement it for a compact binary format. Inflicting it on a text-based format just seems like it'd multiply the pain...
Re:JSON with Commas and Comments by nly on Tuesday February 23, 2021 @05:31AM (#26235706)
The resulting JSON was pretty clean, no worse than you'd get out of Flatbuffers or Protocol Buffers JSON encoding.

It was very handy to be able to use jq on the data.