ASN.1 and JSON conversion rules

Conversion of ASN.1 primitive types into JSON are defined here. Main rules of ITU-T X.697 specifications are followed.

Unsupported ASN.1 structures

Some ASN.1 structures are not supported for JSON conversion:

  • REAL

  • ENUMERATED

These types are not used by ICAO and eIDAS.

Differences with ITU-T X.697 specifications

ASN.1 ANY

An ASN.1 ANY element is encoded as a JSON string in hexadecimal format (containing only 0123456789ABCDEF characters). Returned string will contain DER Tag, Length and Value.

ASN1.1 named BIT STRING

If applicable, an ASN.1 named BIT STRING element is encoded as a JSON object, and:

  • for each named BIT, there is a JSON key with same name

  • corresponding JSON value is true or false, depending on corresponding BIT value