ASN.1 is formal notation for describing data structures. An international standard, ASN.1 is used almost everywhere, but it works so well it's invisible.
It has proven to be the most interoperable means for describing information exchanged between systems. It is heavily used in telecommunications protocols (it's in your cellphone), Intelligent Transportation (cars talking to each other and with road infrastructure), IoT (sensors in smart homes/cities), Security/Fintech (encryption, financial data), RFID, Aviation/Satellite and other protocols that require robust communication.
Using ASN.1, you describe your data and an ASN.1 compiler will ensure that the generated code will encode and decode exactly in the same way without any effort from the user's side, in any programming language and on any platform.
Modern communication calls for more structure in the messages being exchanged, while maintaining enough flexibility to deal with an unpredictable, evolving environment.
ASN.1 takes care of the former by its very nature, i.e., it describes data in an abstract schema, independent of the bits-on-the-wire, and it validates messages for conformance with this schema. ASN.1 can easily handle the latter via support for JSON and tagged binary encodings, which are robust enough to withstand deviations from schema or even no schema at all.
Today there are many options for describing data structures that will be used by communication endpoints. Choices range from binary protocols such as Google Protocol Buffers or Apache Thrift, to text based protocols such as JSON (using JSON Schema).
So why ASN.1?
- Simple and intuitive, yet advanced features allow for complex scenarios too
- Supports JSON and multiple standard binary formats
- It is an international standard
- Proven backward compatibility
- Platform and programming language independent
- It is patent-free
- Much more compact than other popular schemas, which makes the schema much easier to read and understand (schema size less than 20% in typical cases)
- ASN.1 schema keeps data semantics in check and ensures interoperability between systems
- Automatic tags for fields means that you get cleaner, more readable schemas (no need to add a tag number for each field)
Broadly speaking, the ASN.1 schema, while offering the same validation semantics is more compact and easier to read and understand by a human. This is especially useful for large schemas. Try generating an ASN.1 schema for your JSON message here.