Chapter 10. Generated JSON Encode Methods

Table of Contents

Generated Method Format and Calling Parameters
Populating Generated Variables for Encoding
Procedure for Calling JSON Encode Methods
Reuse of C# Encoding Objects

Encoding to JSON is similar to other encoding rules. For each ASN.1 production defined in an ASN.1 source file, an encode method may be generated. This function will convert a populated variable of the given type into an encoded ASN.1 message.

An encode method is only generated if it is required to alter the behavior of the base class. The C# model is built on inheritance from a set of common run-time base classes. These run-time classes contain default implementations of encode/decode methods that handle the encoding/decoding of the basic types. The generated classes for all constructed types (SEQUENCE, SEQUENCE OF, and CHOICE) will include generated encode methods.

Note

Rules for encoding values of ASN.1 types to JSON have not be standardized. We follow the specification available on our webiste at http://www.obj-sys.com/docs/JSON%20Encoding%20Rules.pdf