OPC UA JSON
The Twin Microservice REST API uses OPC UA JSON reversible encoding as per standard defined in OPC UA specification 1.04, Part 6, with the following exceptions or enhancements:
nullvalues are not encoded. A missing value implies
Default scalar values are not encoded except when inside of an array.
In addition to the standard string encoding using a namespace index (e.g.
ns=4;i=3) or the expanded format (e.g.
nsu=http://opcfoundation.org/UA/;i=3523) the API supports and encourages the use of URI encoded Node Ids (see RFC 3986).
The API itself does not support specifying JSON Object encoded Node Id, however, values can contain them. All responses include node identifiers in the Uri format.
It is recommended to always use the URI form of Node Id since it is independent of the server and session’s namespace table state.
Non Uri namespace Uri’s must be encoded using the nsu syntax (e.g.
Expanded Node Identifiers can also be encoded using the OPC UA defined syntax (e.g.
src=opc.tcp://test;nsu=http://opcfoundation.org/UA/;i=3523). However, all requests accept and responses return a URI encoded Expanded Node Id, which differs from the regular Node Id URI format only if a server URI is specified. In this case the server URI is appended as
All primitive built-in values (
double, etc.) and Arrays of them can be passed as JSON encoded Variant objects (as per standard) or as JSON Token. The twin module attempts to coerce the JSON Token in the payload to the expected built-in type of the Variable or Input argument.
The decoder will match JSON variable names case-insensitively. This means you can write a JSON object property name as
"typeid": "", or
"TYPEID": ""and all are decoded into a OPC UA structure’s
Qualified Names are encoded as a single string the same way as Node Ids, where the name is the ID element of the URI, URL encoded, e.g.
While not always enforced, ensure you URL encode the id value or name of Qualified Names, Node Ids and Expanded Node Ids.