View Issue Details

IDProjectCategoryView StatusLast Update
000879210000-006: MappingsSpecpublic2023-05-16 15:34
ReporterThilo Bellinger Assigned ToRandy Armstrong  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.05.02 RC1 
Fixed in Version1.05.03 RC1 
Summary0008792: Unclear and missing description about Enumerations in Variants (mainly for JSON encoding)
Description

It may look pedantic, but it is not really clear if an Enumeration can hold an Enumeration directly or if an Enumeration must be converted to another data type (usually Int32) to be stored in a Variant.
This distinction matters for JSON encoding.

For binary and XML encoding it does not matter since Enumeration values in Variants are always sent as Int32.

For the JSON reversible encoding it is not described as which data type an Enumeration shall be sent within a Variant, the value is a number but the Type number is unknown.
For the JSON non-reversible encoding, the Type number is dropped, but it is not clear if the content should be sent as the string representation (non-reversible Enumeration) or the numeric representation (Int32 representation).

I assume the Enumeration value in a Variant should be sent in the same way as it would be sent directly:
For reversible as numeric, e.g. Int32 ("Type": 6).
For non-reversible as string representation. The variant fields are not visible for non reversible so the value should also look similar as directly encoded.

  • The general desciption about Variant states: "A Variant is a union of all built-in data types including an ExtensionObject."
  • Enumeration is not listed as a built-in data type
  • The XML encoding for Enumeration states: "Enumerations that are stored in a Variant are encoded as an Int32 value."

Can a Variant hold an Enumeration?
Should an Enumeration be converted to another data type to be transported in a Variant?
If yes, then the text for the XML Enumeration encoding text is misleading.
The encoding rules for JSON Enumerations in Variants are missing in any case.

TagsNo tags attached.
Commit Version
Fix Due Date

Activities

Randy Armstrong

2023-05-11 20:47

administrator   ~0019328

The issue is not clear.

The Variant definition says:
If the value is a scalar, it is encoded using the rules for type specified for the Type.

For the reversible it would be encoded as a number.
So for non-reversible the variant would be the non-reversible encoding of the enumeration or a simple string.

There is no inconsistency with XML because XML does not have a non-reversible encoding.
The JSON and XML rules for reversible encoding are the same.

Thilo Bellinger

2023-05-12 09:47

reporter   ~0019342

  1. From the common description it looks like Enumeration is not directly supported in a Variant (neither listed as built-in type nor an ExtensionObject).
    Binary and XML describe that Enumerations in Variants are encoded as Int32.
    In these cases I interprete it like "store the enumeration as Int32 in the variant and encode it".
    There is no such extra statement how to encode an Enumeration inside a Variant for JSON or I did not find any.

The problem is that our SDK is currently not able to store the full information of an Enumeration value (type name, value name and number) inside our variant data structure to select the representation via the JSON reversible flag.
Once stored as Int32 it is always encoded as Int32.

  1. A Variant for reversible has to encode the used built-in type in the "Type" field but JSON number is not a UA built-in data type.
    We need to know which type ID to encode here even though the "Body" is the same.
    The related built-in type Int32 is specific for Binary and XML but not described for JSON.
    This obviously does not matter for non-reversible as the Variant "Type" field is omitted.

Randy Armstrong

2023-05-13 16:21

administrator   ~0019368

Added text:

If an enumeration is encoded using in the reversible encoding within a Variant, the Type field is Built-in Type Int32.

Jim Luth

2023-05-16 15:34

administrator   ~0019378

Agreed to changes edited in Web meeting.

Issue History

Date Modified Username Field Change
2023-04-13 17:45 Thilo Bellinger New Issue
2023-04-18 15:19 Jim Luth Assigned To => Randy Armstrong
2023-04-18 15:19 Jim Luth Status new => assigned
2023-05-11 20:47 Randy Armstrong Status assigned => feedback
2023-05-11 20:47 Randy Armstrong Note Added: 0019328
2023-05-12 09:47 Thilo Bellinger Note Added: 0019342
2023-05-12 09:47 Thilo Bellinger Status feedback => assigned
2023-05-13 16:21 Randy Armstrong Status assigned => resolved
2023-05-13 16:21 Randy Armstrong Resolution open => fixed
2023-05-13 16:21 Randy Armstrong Note Added: 0019368
2023-05-16 15:34 Jim Luth Status resolved => closed
2023-05-16 15:34 Jim Luth Fixed in Version => 1.05.03 RC1
2023-05-16 15:34 Jim Luth Note Added: 0019378