13.4.2.2. Script Execution

JSON is a recursive notation. Any object field or array element in a JSON document can have any type as its value, including other objects and arrays, to arbitrary depth. To process the incoming JSON message, the parser recursively visits every field and array element in the document, and executes callback functions that you provide at every level.

There are four callback functions that are called during this descent. It is the responsibility of the system integrator to provide these callbacks.

When a point name is computed from a JSON path, the default behaviour is to construct the point by concatenating the default domain, a colon and the path field names separated by dot characters. For array elements, the default is to append an open bracket ( [ ), an index starting at zero, and a closed bracket ( ] ) to the preceding path. The parser provides two callbacks to modify this behaviour:

When a topic is identified as producing a specific schema for the first time, that topic is associated with that schema to speed up processing for subsequent messages. When that association is made, a callback will be executed if it is defined:

When the callback functions run, the following variables are defined to provide context for the callback:

For the Message options, the variable msg contains client information for use when configuring the Advanced Parser.

If your script references a data point structure, such as that returned by app.ReadPoint or in the point variable in a publish format, you can access some of the metadata associated with the point. This information can be read by your script, but must not be modified.

Starting with DataHub version 11, the following will also be available: