Three types of Python decode functions/methods are available for decoding different types of data. These are:
Standard base run-time functions. These exist in the
asn1json.py
run-time module, in the
Asn1JsonDecodeBuffer
run-time class. Examples are decode_bitstring
and decode_real
. For some types, which are
closely aligned with the JSON representation, read* methods are
used, such as read_boolean
and
read_string
. These methods return a
representation of the decoded value.
Static methods in Python classes, such as for primitive types
and SEQUENCE/SET OF
, as described above.
The method name in this case is json_decode
.
The return value will be the Python class that represents values of
the ASN.1 type, whether that is a built-in class or from the ASN1C
Python runtime.
Instance methods in Python classes for constructed types.
Classes are generated for SEQUENCE
,
SET
, and CHOICE
constructs.
The decode method in this case decodes into the instance attributes
which correspond to the ASN.1 elements defind in the ASN.1 types.
The method name is also json_decode
, as it was
in the static method case. There is no return value.
The generated decode methods accept an
Asn1JsonDecodeBuffer
, the buffer to decode from.
Example signatures are:
@staticmethod def json_decode(decbuf): def json_decode(self, decbuf):
All decode methods raise an exception if decoding fails.