Custom Data Types

Custom Data Types are objects. Each application can have access to arbitrarily many Custom Data Types, which are accessed and edited in the AirData Builder. Each Custom Data Type consists of any number of properties, structured into key-value pairs. The expected Data Type of each property is also defined in the AirData Builder. A property can expect any primitive Data Type as well as other Custom Data Types.

In concept and in practice, Custom Data Types are similar to AirData App Objects. The fundamental difference is that AirData App Objects define a way to structure data that can be saved to AirData, whereas Custom Types can only be used to define local variables for reference within the context of a Journey.

Structure

Custom Data Types must be objects, consisting of any number of key-value pairs. Beyond that, their structure is, as the name implies, highly customizable. Structuring the Custom Data Type is a part of the creation process.

There are two ways to create a new Custom Data Type:

  1. Create a new Custom Type and manually define all of it's properties in AirData Builder.
  2. Save the structure of data returned by a Data Operation from Connections Builder.

Examples

Structuring Custom Data Types in AirData Builder

Custom Data Types are created in the AirData Builder by clicking on the '+' icon to the right of the Custom Types branch in the Tree:

organizing infoorganizing info

Upon creation, it is best practice to rename the Custom Data Type so that it is self-documenting. Do this by double-clicking directly on the Custom Data Type within the Tree and typing a more descriptive name:

organizing infoorganizing info

Add any number of properties to the Custom Data Type by clicking the '+' icon to the right of the relevant Custom Data Type, which provides the option to select the Data Type of the property:

organizing infoorganizing info

Properties names are edited in the same way as the Custom Data Types names.

As properties are added to a Custom Data Type, the Stage displays an example how the Custom Data Type might appear in Airscript. Note how properties within the DateTime property, datetime_property, are nested:

organizing infoorganizing info

Saving the Structure of Incoming Data from Connections Builder

Several Data Operations return output that might potentially be structured as an object. In such cases, the bottom left of the Data Operation as displayed the Stage of the Connections Builder will contain the following button:

organizing infoorganizing info

Clicking on this button saves the structure of the Data Operation's current returned value as a new Custom Type. For example, say the HTTP Request Data Operation is run, returning the following JSON object:

organizing infoorganizing info

Upon clicking the Save Type button, the following Custom Data Type will be automatically generated in AirData Builder:

Note that the properties associated with this automatically-generated Custom Data Type correspond to the properties of the JSON object returned by the earlier HTTP Request.

The names of Custom Data Types generated in this way can be edited in the same was as any other Custom Data Type: double-clicking directly on the Custom Data Type within the Tree and typing a new name.

Using Custom Data Types

Once the structure of a Custom Data Type has been finalized, it can be used to define variables just like any other Data Type.

Reference properties within a Custom Data Type using dot notation. For instance, assuming the a variable of the Auto-Generated Type described in the above screenshot is designated autogenerated_type and contains the following value:

{
  "activity": "Draw something interesting",
  "type": "recreational",
  "participants": 1,
  "price": 0,
  "link": "",
  "key": "8033599",
  "accessibility": 0
}

The activity property would be referenced as follows:

autogenerated_type.activity -> "Draw something interesting"

Similarly, the participants property is referenced as follows:

autogenerated_type.participants -> 1