Any value for a nullable Built-In type that is NULL shall be encoded as the JSON literal ‘null’ if the value is an element of a JSON array. If the NULL value is for a field within a JSON object, the field shall be omitted when using the CompactEncoding. When using the VerboseEncoding, the field is encoded as the JSON literal ‘null’.

Any non-nullable Built-In type shall be encoded if it is an element of an array. When using the CompactEncoding, the field of a Structure or Union is omitted if value is equal to the default value for the Built-In type.

Note that JSON objects are unordered sets of name-value pairs. When a Built-In type is encoded as a JSON object, the order of fields specified is not preserved.

A Boolean value shall be encoded as the JSON literal ‘true’ or ‘false’.

Integer values other than Int64 and UInt64 shall be encoded as a JSON number.

Int64 and UInt64 values shall be formatted as a decimal number encoded as a JSON string

(See the XML encoding of 64-bit values described in 5.3.1.3).

Normal Float and Double values shall be encoded as a JSON number.

Special floating-point numbers such as positive infinity (INF), negative infinity (-INF) and not-a-number (NaN) shall be represented by the values “Infinity”, “-Infinity” and “NaN” encoded as a JSON string. See 5.2.2.3 for more information on the different types of special floating-point numbers.

String values shall be encoded as JSON strings.

Any characters which are not allowed in JSON strings are escaped using the rules defined in RFC 8259.

Strings with embedded nulls (‘\u0000’) are not guaranteed to be interoperable because not all DevelopmentPlatforms can handle Strings with embedded nulls. For this reason, embedded nulls are not recommended. Encoders may encode Strings with embedded nulls. Decoders shall read all bytes in String; however, decoders may truncate the String at the first embedded null before passing it on to the application.

DateTime values shall be formatted as specified by ISO 8601-1 and encoded as a JSON string.

DateTime values which exceed the minimum or maximum values supported on a platform shall be encoded as “0001-01-01T00:00:00Z” or “9999-12-31T23:59:59Z” respectively. During decoding, these values shall be converted to the minimum or maximum values supported on the platform.

ISO 8601-1 DateType values may specify an arbitrary number of decimal places representing fractions of seconds. Encoders shall support as many decimal places needed to represent the full range of the DateTime type on their DevelopmentPlatform. Decoders may truncate decimal places that exceed the range supported by the DateTime type on their DevelopmentPlatform.

DateTime values equal to “0001-01-01T00:00:00Z” are considered to be NULL values.

Guid values shall be formatted as described in 5.1.3 and encoded as a JSON string.

ByteString values shall be formatted as a Base64 text and encoded as a JSON string.

Any characters which are not allowed in JSON strings are escaped using the rules defined in RFC 8259.

XmlElement value shall be encoded as a String as described in 5.4.2.5.

NodeId values shall be encoded as a JSON string using the format defined in 5.1.12. NodeIds in NamespaceIndex 0 use the <identifier> form. All other NodeIds use the <namespace-uri> form.

The first abnormal state occurs when the encoder cannot map a NamespaceIndex to a NamespaceUri. In this case, the encoder shall encode the NamespaceIndex using the <namespace-index> form. The decoder shall pass this NamespaceIndex to the application.

The second abnormal state occurs when the decoder cannot convert a NamespaceUri to a NamespaceIndex. If this occurs the decoder shall set the NamespaceIndex to 0, the IdType to String and the Identifier to the JSON string.

ExpandedNodeId values shall be encoded as a JSON string using the format defined in 5.1.12. The NodeId portion of the ExpandedNodeId uses the rules from 5.4.2.10.ExpandedNodeIds with a ServerIndex of 0 are encoded using the <node-id> form. All other ExpandedNodeIds use the <server-uri> form unless the first abnormal state occurs as described below.

The first abnormal state occurs when the encoder cannot map a ServerIndex to a ServerUri. In this case, the encoder shall encode the ServerIndex using the <server-index> form. The decoder shall pass this ServerIndex to the application.

The second abnormal state occurs when the decoder cannot convert a ServerUri to a ServerIndex. If this occurs the decoder shall set the ServerIndex to 0, the NamespaceIndex to 0, the IdType to String and the Identifier to the JSON string.

When the ServerIndex is 0, decoders shall replace a NamespaceUri with a NamespaceIndex when a mapping exists or if a mapping can be created. If no mapping exists or one cannot be created the NamespaceUri is stored in the NamespaceUri field of the ExpandedNodeId.

StatusCode values shall be encoded as a JSON object with the fields defined in Table 36.

Table 36 – JSON Object Definition for a StatusCode

Name

Description

Code

The numeric code encoded as a JSON number.

The Code is omitted if the numeric code is 0 (Good).

Symbol

The string literal associated with the numeric code encoded as JSON string.

e.g. 0x80AB0000 has the associated literal “BadInvalidArgument”.

Any InfoBits in the StatusCode are ignored when looking up the symbol.

If the string literal is not known to the encoder the field is omitted.

The field is omitted in the CompactEncoding.

The field is omitted if the numeric code is 0 (Good).

The recommended string literals are defined in A.2.

DiagnosticInfo values shall be encoded as a JSON object with the fields shown in Table 37.

Table 37 – JSON Object Definition for a DiagnosticInfo

Name

Data Type

Description

SymbolicId

Int32

A symbolic name for the status code.

The default value is -1.

It is not encoded if the value is -1.

NamespaceUri

Int32

A namespace that qualifies the symbolic id.

The default value is -1.

It is not encoded if the value is -1.

Locale

Int32

The locale used for the localized text.

The default value is -1.

It is not encoded if the value is -1.

LocalizedText

Int32

A human readable summary of the status code.

The default value is -1.

It is not encoded if the value is -1.

AdditionalInfo

String

Detailed application specific diagnostic information.

The default value is null.

It is not encoded if the value is null.

InnerStatusCode

StatusCode

A status code provided by an underlying system.

The default value is Good.

It is not encoded if the value is Good.

InnerDiagnosticInfo

DiagnosticInfo

Diagnostic info associated with the inner status code.

The default value is null.

It is not encoded if the value is null.

The SymbolicId, NamespaceUri, Locale and LocalizedText fields are encoded as JSON numbers which reference the StringTable contained in the ResponseHeader.

DiagnosticInfo is recursive and unlimited recursion could result in stack overflow errors even if the message size is less than the maximum allowed. Decoders shall support at least 4 recursion levels and are not expected to support more than 10. Decoders shall report an error if the number of recursion levels exceeds what it supports.

QualifiedName values shall be encoded as a JSON string using the format defined in 5.1.12 however, the form with the NamespaceIndex is not allowed.

When decoders need to replace a NamespaceUri with a NamespaceIndex and the NamespaceUri cannot be mapped to a NamespaceIndex, then decoders shall use 0 for the NamespaceIndex and the JSON string as the Name.

LocalizedText values shall be encoded as a JSON object with the fields shown in Table 38.

Table 38 – JSON Object Definition for a LocalizedText

Name

Description

Locale

The Locale portion of LocalizedText values shall be encoded as a JSON string.

The field is not encoded if it is null or empty.

Text

The Text portion of LocalizedText values shall be encoded as a JSON string.

The field is not encoded if it is null or empty.

The ExtensionObject is encoded as a JSON object as described in:

with the UaTypeId field inserted into the JSON object.

Decoders shall report decoding errors to the application if a JSON object has multiple fields with the same name.

The UaEncoding and UaBody fields are only used when UA Binary or UA XML encoded Structures are serialized. Only the fields in Table 39 are present if these fields are used.

The JSON object fields used for an ExtensionObject are in Table 39.

Table 39 – JSON Object Fields used for an ExtensionObject

Name

Description

UaTypeId

A NodeId formatted using the rules in 5.4.2.10.

This is the NodeId of a DataType Node.

UaEncoding

A JSON number that represents the format of the UaBody field.

A value of 1 indicates UA Binary data is encoded in the UaBody field.

A value of 2 indicates UA XML data is encoded in the UaBody field.

This field is omitted for JSON encoded Structures.

UaBody

A ByteString containing an UA Binary or UA XML encoded Structure.

This field is omitted for JSON encoded Structures.

Encoders, when allowed by the DevelopmentPlatform, should write the UaTypeId first. Decoders shall accept the UaTypeId in any position.

Variant values shall be encoded as a JSON object with the fields shown in Table 40.

Table 40 – JSON Object Definition for a Variant

Name

Description

UaType

The Built-in type for the value contained in the Body (see Table 1) encoded as JSON number.

Value

If the value is a scalar, it is encoded using the rules for type specified for the Type.

If the value is a one-dimensional array it is encoded as JSON array (see 5.4.5).

Multi-dimensional arrays are encoded as a JSON array containing all elements. The mapping of a multidimensional array to a flat list is described in 5.2.2.16.

The field is not encoded if the value is a NULL for nullable Built-in types (see Table 1).

Dimensions

The dimensions of the array encoded as a JSON array of JSON numbers.

Encoders, when allowed by the DevelopmentPlatform, should write the UaType first. Decoders shall accept the UaType field in any position.

DataValue values shall be encoded as a JSON object with the fields shown in Table 41.

The DataValue adds additional fields to a Variant (see 5.4.2.17).

Table 41 – JSON Object Definition for a DataValue

Name

Data Type

Description

UaType

Byte

See the UaType field in the Variant.

Value

*

See the Value field in the Variant.

Dimensions

UInt32

See the Dimensions field in the Variant.

Status

StatusCode

The status associated with the value.

Not encoded if the value is Good (0).

SourceTimestamp

DateTime

The source timestamp associated with the value.

Not encoded if the value is DateTime.MinValue.

SourcePicoseconds

UInt16

The number of 10 Picosecond intervals for the SourceTimestamp.

Not encoded if the value is 0.

ServerTimestamp

DateTime

The Server timestamp associated with the value.

Not encoded if the value is DateTime.MinValue.

ServerPicoseconds

UInt16

The number of 10 Picosecond intervals for the ServerTimestamp.

Not encoded if the value is 0.