Unionsshall be encoded as JSON objects as shown in Table 41for the reversible encoding.

Table 41– JSON Object Definition for a Union




The identifier for the field in the Union which is encoded as a JSON number.

The valid values for this field follow the conventions defined in 5.2.8.

If the SwitchFieldvalue is its DefaultValueof 0, then the SwitchFieldand the Valuefield are not present.


The value of the field encoded using the rules that apply to the data type.

For the non-reversible form, Unionvalues are encoded using the rule for the current value. If the SwitchFieldis 0 the Unionis encoded as a JSON null value.

For example, instances of the union:

struct Union1


Byte Selector;


Int32 A;

Double B;

Char* C;




would be represented in reversible form as:

{ "SwitchField":2, "Value":3.1415 }

In non-reversible form, it is represented as: