Arrays

Arrays can be created from simple data types and complex objects.

Array of simple data types

Simple data types are specified within the "items" property under the "type" data type property. The following schema defines an array of strings.

{
   "$schema": "http://json-schema.org/draft-04/schema",
   "definitions": {
      "CustomDatatype": {
         "$schema": "http://json-schema.org/draft-04/schema",
         "title": "CustomDatatype",
         "type": "array",
         "items": {
            "type": "string"
         }
      }
   }
}

This schema generates the following generic data editor in Engineering.

Arrays 1:

The generic data editor displays the array elements on the rleft-hand side under the name of the respective data type (in the example: string). If a self-defined name is to be displayed instead, an object with a property of the type of the data type must be selected instead of the simple data type, and the "displayName" of the property must be set in the metadata.

Array of complex data types

Complex data types are specified in the property "items" under the reference property "$ref". The following schema defines an array of objects of data type "CustomDatatype". This data type was previously implemented as Object.

{
   "$schema": "http://json-schema.org/draft-04/schema",
   "definitions": {
      "MyArray": {
         "$schema": "http://json-schema.org/draft-04/schema",
         "title": "MyArray",
         "type": "array",
         "items": {
            "$ref": "tchmi:framework#/definitions/CustomDatatype"
         }
      }
   }
}

Furthermore, it is possible to describe the object directly within the array definition. The following schema describes the same array with the definition of the object within the property "items".

{
   "$schema": "http://json-schema.org/draft-04/schema",
   "definitions": {
      "MyArrayInlineObject": {
         "$schema": "http://json-schema.org/draft-04/schema",
         "title": "MyArrayInlineObject",
         "type": "array",
         "items": {
            "type": "object",
            "title": "CustomObject",
            "description": "Defines a custom object in the array.",
            "propertiesMeta": [
                  {
                     "name": "axisName",
                     "category": "Name",
                     "displayName": "Axis Name",
                     "displayPriority": 10,
                     "description": "",
                     "defaultValue": null,
                     "defaultValueInternal": null
                  },
                  {
                     "name": "axisColor",
                     "category": "Colors",
                     "displayName": "Axis color",
                     "displayPriority": 10,
                     "description": "",
                     "defaultValue": null,
                     "defaultValueInternal": {
                     "color": "#4794da"
                  }
               }
            ],
            "properties": {
               "axisName": {
                  "type": "string"
               },
               "axisColor": {
                  "$ref": "tchmi:framework#/definitions/SolidColor"
               }
            },
            "required": [ "axisName" ]
         }
      }
   }
}

Both schema files generate the following generic data editor in Engineering.

Arrays 2: