Chapter 14. Generated JER (JSON Encoding Rules) Functions

Table of Contents

Generated JSON Encode Functions
Generated JSON Decode Functions

JavaScript Object Notation (JSON) is a minimal format for exchanging data. This marries a well-known simple text format (JSON) with a robust and mature schema language (ASN.1) and provides a possible interchange between JSON and ASN.1 binary formats like BER or PER.

As of version 7.3, ASN1C supports ITU-T X.697 JER. BACKWARD COMPATIBILITY: Prior versions (starting with asn1c 6.6) used proprietary encoding rules for JSON, as this work predated the development of ITU-T X.697. If you need to work with our proprietary encoding rules, you must use the command-line arguments -compat 729 (or an older version number). We urge you to upgrade to using X.697 JER.

Our proprietary rules, and differences with X.697, are available on our website.

To generate encoding and decoding functions, use the -json switch on the command-line or select the appropriate option in the GUI. The following sections describe the generated encoding and decoding functions. Descriptions of the JSON run time functions may be found in our C JSON Runtime Library Reference Manual. C++ classes are described in the C++ JSON Runtime Libarary Reference Manual.

As of version 7.4, the -jer+ option generates code for JER with some ObjSys extensions/revisions. In particular, the encoder will encode a content-constrained BIT STRING or OCTET STRING as the contained type, inside a wrapper, rather than as a BIT STRING or OCTET STRING (which would use a hexadecimal representation). The decoder will successfully decode values encoded in either the extended format or in the standard JER format. The extended format is a JSON object with a value named "value+" where the value is the normal JER encoding of the contained type. For example:

"bit-string-field" : {
         "value+" : <JER encoding of contained type>
         }