[ACCEPTED]-ASN.1 vs JSON when is is appropriate to use them?-asn.1
ASN.1 and JSON aren't strictly comparable. JSON 9 is a data format. ASN.1 is a schema language 8 plus multiple sets of encoding rules, each 7 of which produces different data formats 6 for a given schema. So, the original question 5 somewhat parallels the question "XML 4 Schema vs. XML: when is it appropriate to 3 use them?" A fairer comparison would 2 be between ASN.1 and JSON Schema.
That said, a 1 few points to consider:
- ASN.1 has binary encoding rules. Consider whether binary or text encoding is preferable for your application.
- ASN.1 also has XML and JSON encoding rules. You can opt to go with a text-based encoding using ASN.1, if you like.
- ASN.1 allows other encoding rules to be developed. Before ITU-T specified encoding rules for JSON, we specified our own rules to encode ASN.1 to JSON. I blogged about this on our company website here
- As with XML Schema, tools exist for compiling ASN.1. These are commonly referred to as data binding tools. The compiler output consists of data structures to hold your data, and code for encoding/decoding to/from the various encodings (binary, XML, JSON).
- I am not sure what, if any, data binding tools exist for JSON Schema. I am also not sure how mature/stable JSON Schema is, whereas ASN.1 is quite mature and stable.
- Choosing between JSON Schema and ASN.1, note that JSON Schema is bound to JSON, whereas ASN.1 is not bound to any particular representation.
You can use ASN.1 regardless of whether 19 you need to serialize messages that might 18 go to a recipient using C, C++, C#, Java, or 17 any other programming language with ASN.1 16 encoder/decoder engine. ASN.1 also provides 15 multiple encoding rules which have benefits 14 under different circumstances. For example, DER 13 is used when a canonical encoding is crucial, such 12 as in digital certificates, while PER is 11 used when bandwidth is critical such as 10 in cellular protocols, and E-XER is used 9 when you don't care about bandwidth and 8 would like to display an encoding in XML 7 for maniplulation in a browser or exchange 6 messages with an XML Schema engine.
Note 5 that with a good ASN.1 tool, you don't have 4 to change you application code to switch 3 between these ASN.1 encoding rules. A simple 2 function call can select the encoding rules 1 you would like to use.
Here can found a papper with a great study of 1 JSON, XML, ASN.1, EXI and ProtoBuf
More Related questions