13.4.2.5. Parser Script

This is the main processing script that runs each time a new message arrives. The message has already been validated against the schema, so the script can assume that any required fields are present in the resulting input.Json object.

There are two broad approaches to processing a message.

  1. Call app.ProcessJson(). This recursively descends through the JSON object, applying callbacks at each stage.

  2. Manually extract information from the input.Json object and construct app.WritePoint calls from that information.

Before calling app.ProcessJson, you can extract specific information from input.Json to set variables that will be used by the processing callbacks. One common case is a message that contains a single timestamp and multiple data values. In that case, you could extract the timestamp and store it in a local variable, then create a custom app.ValueProcessor that writes a data point value using app.WritePoint with this timestamp. To avoid creating a new data point containing this timestamp, set app.ExcludePaths to omit the JSON field containing the timestamp.

When working with JSON tokens, all public members of JToken, JArray, JObject and JProperty are supported. See the Newtonsoft.Json.Linq documentation for more information. In addition to the built-in methods, the following methods are also available:

The following functions are available to interpret timestamps. All UNIX and JSON timestamps are assumed to be in UTC. All DateTime results from timestamp conversion functions are explicitly in UTC.