5 Data encoding ToC Previous Next

5.4 OPC UA JSON ToC Previous Next

5.4.6 Structures ToC Previous Next

Structures shall be encoded as JSON objects.

Fields which are NULL or have a default value shall be encoded using the rules shown in Table 38.

Table 38 – JSON Encoding Rules for Structures

Field Value Reversible Non-Reversible
NULL Omitted JSON null
Default Value Omitted Default Value

For example, instances of the structures:

struct Type2
{
Int32 A;
Int32 B;
Char* C;
};

struct Type1
{
Int32 X;
Int32 NoOfY;
Type2* Y;
Int32 Z;
};

The reversible encoding is represented in JSON as:

{
"X":1234,
"Y":[ { "A":1, "B":2, "C":"Hello" }, { "A":3, "B":4 } ],
"Z":5678
}

Where “C” is omitted from the second Type2 instance because it has a NULL value.

The non-reversible encoding is represented in JSON as:

{
"X":1234,
"Y":[ { "A":1, "B":2, "C":"Hello" }, { "A":3, "B":4, "C":null } ],
"Z":5678
}

Where “C” in the second Type2 instance has a JSON null value.

Previous Next