When you call API operations that are related to Thing Specification Language (TSL) models, the request parameters or response parameters may contain the ThingModelJson parameter. The value of this parameter indicates the TSL data structure that is stored in IoT Platform. This TSL data structure is different from the original TSL data structure. All fields in the ThingModelJson parameter are sorted by key in alphabetical order.

For information about the limits of TSL features, see Limits.

Data structure

The data structure of a default TSL module is different from that of a custom TSL module.

  • Default TSL module
    {
      "_ppk":{
           "description":"test",
           "version":"159244410****"
      }
      "events":[],
      "productKey":"al12345****",
      "properties":[],
      "services":[],
      "functionBlocks":[{
          "productKey":"al12345****",
          "functionBlockId":"location0",
          "functionBlockName":"Location module 0"
        }]
    }
    ParameterTypeDescription
    productKeyStringThe ProductKey of the product to which the TSL model belongs.
    _ppkStringThe information about the TSL model version. This parameter consists of the following fields:
    • version: the version number of the current TSL model. This field is available only for published TSL models.
    • description: the description of the current TSL model. This field is available only for published TSL models.
    propertiesListThe properties of the product to which the TSL model belongs. For more information about the data structure of the properties parameter, see Data structure of the properties parameter.

    In each property, you can use the extendConfig parameter to define the extended information about the TSL model. For more information, see Data structure of the extendConfig parameter. If no extended information needs to be defined, you do not need to specify the extendConfig parameter.

    servicesListThe services of the product to which the TSL model belongs. For more information about the data structure of the services parameter, see Data structure of the services parameter.

    In each service, you can use the extendConfig parameter to define the extended information about the TSL model. For more information, see Data structure of the extendConfig parameter. If no extended information needs to be defined, you do not need to specify the extendConfig parameter.

    eventsListThe events of the product to which the TSL model belongs. For more information about the data structure of the events parameter, see Data structure of the events parameter.

    In each event, you can use the extendConfig parameter to define the extended information about the TSL model. For more information, see Data structure of the extendConfig parameter. If no extended information needs to be defined, you do not need to specify the extendConfig parameter.

    functionBlocksListThe list of custom modules. This parameter is available only when the product contains at least one custom TSL module. This parameter consists of the following fields:
    • productKey: the ProductKey of the product to which the TSL model belongs.
    • functionBlockId: the identifier of the custom TSL module. Each identifier is unique in a product.
    • functionBlockName: the name of the custom TSL module.
  • Custom TSL module
    {
      "productKey":"al12345****", 
      "identifier":"location0",
      "name":"Location module 0",
      "properties":[],
      "services":[],
      "events":[],
      "description":""
    }

    The following table describes the parameters of a custom TSL module, excluding those inherited from the default TSL module.

    ParameterTypeDescription
    identifierStringThe identifier of the custom TSL module. Each identifier is unique in a product.

    The identifier must be 1 to 30 characters in length, and can contain letters, digits, and underscores (_).

    nameStringThe name of the custom TSL module.

    The name must be 4 to 30 characters in length, and can contain letters, digits, and underscores (_).

    descriptionStringThe description of the custom TSL module. The description can be up to 100 characters in length.

Data structure of the properties parameter

The following table describes the parameters that are used to define a property.

Important The std and customFlag parameters that were used in the previous versions of APIs have been phased out. Therefore, no description is provided for these parameters in this section. When you call API operations, you do not need to specify these two parameters.
ParameterTypeRequiredDescription
productKeyStringYesThe ProductKey of the product to which the TSL model belongs.
createTsLongNoThe time when the feature was defined. By default, the value is a 13-digit timestamp. You can specify this parameter. If you do not specify this parameter, IoT Platform generates a timestamp. Features are sorted by timestamp in chronological order.
Note For an existing TSL model, its creation time is the time when the TSL model was first modified after it was published.
identifierStringYesThe identifier of the property. The identifier can be up to 50 characters in length and can contain letters, digits, and underscores (_).
Note The identifier cannot be one of the following words: set, get, post, property, event, time, and value.
dataTypeStringYesThe data type of the property value.

Valid values: ARRAY, STRUCT, INT, FLOAT, DOUBLE, TEXT, DATE, ENUM, and BOOL.

You must specify different parameters when different data types are specified. For more information, see the data structure of the corresponding type in this topic.

nameStringYesThe name of the property. The name can be up to 30 characters in length and can contain letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter or digit.
rwFlagStringYesThe type of the operation that IoT Platform can perform on the property. Valid values:
  • READ_WRITE
  • READ_ONLY
dataSpecsObjectNoIf you set dataType to INT, FLOAT, DOUBLE, TEXT, DATE, or ARRAY, the data specifications are included in the dataSpecs parameter.
Note
  • The dataSpecs parameter applies to all data, excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
dataSpecsListListNoIf you set the dataType parameter to ENUM, BOOL, or STRUCT, the data specifications are included in the dataSpecsList parameter.
Note
  • The dataSpecs parameter applies to all data, excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
requiredBooleanYesSpecifies whether the property is required for the standard category. Valid values:
  • true: yes
  • false: no
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes
  • false: no
  • Sample value of the dataSpecs parameter if the dataType parameter is set to INT:
    {
      "dataSpecs": {
        "custom": true,
        "dataType": "INT",
        "defaultValue": "30",
        "max": "1440",
        "min": "0",
        "step": "10",
        "unit": "min"
      }
    }
  • Sample value of the dataSpecs parameter if the dataType parameter is set to TEXT:
    {
      "dataSpecs": {
        "custom": true,
        "dataType": "TEXT",
        "id": 2412127,
        "length": 2048
      }
    }
  • Sample value of the dataSpecs parameter if the dataType parameter is set to ARRAY:
    {
      "dataSpecs": {
        "childDataType": "INT",
        "custom": true,
        "dataType": "ARRAY",
        "size": 1
      }
    }
  • Sample value of the dataSpecsList parameter if the dataType parameter is set to ENUM:
    {
      "dataSpecsList": [
        {
          "custom": false,
          "dataType": "ENUM",
          "defaultValue": "true",
          "name": "Open",
          "value": 1
        },
        {
          "custom": false,
          "dataType": "ENUM",
          "defaultValue": "false",
          "name": "Close",
          "value": 0
        }
      ]
    }
  • Sample value of the dataSpecsList parameter if the dataType parameter is set to STRUCT:
    {
      "childDataType": "TEXT",
      "childName": "Card number",
      "dataSpecs": {
        "custom": true,
        "dataType": "TEXT",
        "length": 128
      },
      "dataType": "STRUCT",
      "identifier": "CardNo",
      "name": "NVR chip information"
    }

Data structure of the services parameter

The following table describes the parameters that are used to define a service.

ParameterTypeRequiredDescription
productKeyStringYesThe ProductKey of the product to which the TSL model belongs.
createTsLongNoThe time when the feature was defined. By default, the value is a 13-digit timestamp. You can specify this parameter. If you do not specify this parameter, IoT Platform generates a timestamp. Features are sorted by timestamp in chronological order.
Note For an existing TSL model, its creation time is the time when the TSL model was first modified after it was published.
identifierStringYesThe identifier of the service. The identifier must be 1 to 50 characters in length and can contain letters, digits, and underscores (_).
Note The identifier cannot be one of the following words: set, get, post, property, event, time, and value.
serviceNameStringYesThe name of the service. The name must be 1 to 30 characters in length and can contain letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter or digit.
inputParamsListNoThe input parameters of the service. For more information about the data structure, see Data structure of the input and output parameters.
outputParamsListNoThe output parameters of the service. For more information about the data structure, see Data structure of the input and output parameters.
requiredBooleanYesSpecifies whether the service is required for the standard category. Valid values:
  • true: yes.
  • false: no.
callTypeStringYesThe method that is used to call the service.
  • ASYNC: asynchronously calls the service.
  • SYNC: synchronously calls the service.
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes.
  • false: no.

Data structure of the events parameter

The following table describes the parameters that are used to define an event.

ParameterTypeRequiredDescription
productKeyStringYesThe ProductKey of the product to which the TSL model belongs.
createTsLongNoThe time when the feature was defined. By default, the value is a 13-digit timestamp. You can specify this parameter. If you do not specify this parameter, IoT Platform generates a timestamp. Features are sorted by timestamp in chronological order.
Note For an existing TSL model, its creation time is the time when the TSL model was first modified after it was published.
identifierStringYesThe identifier of the event. The identifier must be 50 characters in length and can contain uppercase letters, lowercase letters, digits, and underscores (_).
Note The identifier cannot be one of the following words: set, get, post, property, event, time, and value.
eventNameStringYesThe list of one or more event names. The name must be 1 to 30 characters in length, and can contain letters, digits, hyphens (-), underscores (_), and periods (.). The name must start with a letter or digit.
eventTypeStringYesThe type of the event. Valid values:
  • INFO_EVENT_TYPE: information.
  • ALERT_EVENT_TYPE: alert.
  • ERROR_EVENT_TYPE: error.
outputdataListNoThe output parameters of the event. For more information about the data structure, see Data structure of the input and output parameters.
requiredBooleanYesSpecifies whether the event is required for the standard category. Valid values:
  • true: yes.
  • false: no.
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes.
  • false: no.

Data structure of the input and output parameters

The following table describes the parameters that are used to define the input and output parameters of a service or an event.

ParameterTypeRequiredDescription
dataTypeStringYesThe data type of the parameter value.

Valid values: ARRAY, STRUCT, INT, FLOAT, DOUBLE, TEXT, DATE, ENUM, and BOOL.

For more information, see the data structure of the corresponding type in this topic.

identifierStringYesThe identifier of the parameter. The identifier must be 1 to 50 characters in length and can contain letters, digits, and underscores (_).
Note The identifier cannot be one of the following words: set, get, post, property, event, time, and value.
nameStringYesThe name of the request parameter. The name must be 1 to 30 characters in length and can contain letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter or digit.
directionStringYesSpecifies whether the parameter is an input parameter or output parameter. Valid values:
  • PARAM_INPUT: an input parameter.
  • PARAM_OUTPUT: an output parameter.
paraOrderIntegerYesThe serial number of the parameter. The serial number starts from 0 and must be unique.
dataSpecsObjectNoIf you set the dataType parameter to INT, FLOAT, DOUBLE, TEXT, DATE, or ARRAY, the data specifications are included in the dataSpecs parameter.
Note
  • The dataSpecs parameter applies to all data, excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
dataSpecsListListNoIf you set the dataType parameter to ENUM, BOOL, or STRUCT, the data specifications are included in the dataSpecsList parameter.
Note
  • The dataSpecsList parameter applies to all data excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
customBooleanYesSpecifies whether the parameter belongs to a custom TSL feature. Valid values:
  • true: yes.
  • false: no.

Data structure of the INT, FLOAT, or DOUBLE type

The following table describes the parameters that are used to define the data of the INT, FLOAT, and DOUBLE types.

ParameterTypeRequiredDescription
dataTypeStringYesThe type of the data. Valid values: INT, FLOAT, and DOUBLE.
maxStringYesThe maximum value of the parameter. The maximum value is of the INT, FLOAT, or DOUBLE type, as specified by the dataType parameter.

The value of the max parameter must be converted to the data of the STRING type. For example, if the dataType parameter is set to INT, the value of 200 must be expressed as "200" instead of 200.

minStringYesThe minimum value of the parameter. The minimum value is of the INT, FLOAT, or DOUBLE type, as specified by the dataType parameter.

The value of the step parameter must be converted to the data of the STRING type. For more information, see the description of the max parameter.

stepStringYesThe step size, which indicates the increment of each data change. The step size is of the INT, FLOAT, or DOUBLE type, as specified by the dataType parameter.

The value of the step parameter must be converted to the data of the STRING type. For more information, see the description of the max parameter.

preciseStringNoThe precision of the value. You can specify this parameter when the dataType parameter is set to FLOAT or DOUBLE.
defaultValueStringNoYou can specify this parameter to set a default value.
unitStringYesThe symbol of the unit.
unitNameStringYesThe name of the unit.
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes.
  • false: no.

Data structure of the DATE or TEXT type

The following table describes the parameters that are used to define the data of the DATE and TEXT types.

ParameterTypeRequiredDescription
dataTypeStringYesThe type of the data. Valid values: DATE and TEXT.
lengthLongYesThe length of the data. Maximum value: 2048. Unit: bytes. You must specify this parameter if the dataType parameter is set to TEXT.
defaultValueStringNoYou can specify this parameter to set a default value.
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes.
  • false: no.

Data structure of the ARRAY type

The following table describes the parameters that are used to define the data of the ARRAY type.

Important If the data of the ARRAY type and the data of the STRUCT type are nested with each other, at most two layers of recursive nesting are supported.
ParameterTypeRequiredDescription
dataTypeStringYesThe type of the data. Set the value to ARRAY.
sizeLongYesThe number of elements in the array.
childDataTypeStringYesThe data type of the elements in the array. Valid values: STRUCT, INT, FLOAT, DOUBLE, and TEXT.
dataSpecsObjectNoIf you set the dataType parameter to INT, FLOAT, DOUBLE, TEXT, DATE, or ARRAY, the data specifications are included in the dataSpecs parameter.
Note
  • The dataSpecs parameter applies to all data, excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
dataSpecsListListNoIf you set the dataType parameter to ENUM, BOOL, or STRUCT, the data specifications are included in the dataSpecsList parameter.
Note
  • The dataSpecsList parameter applies to all data excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes.
  • false: no.

Data structure of the ENUM or BOOL type

The following table describes the parameters that are used to define the data of the BOOL and ENUM types.

ParameterTypeRequiredDescription
dataTypeStringYesThe type of the data. Valid values: BOOL and ENUM.
nameStringYesThe name of the ENUM item. The name must be 1 to 20 characters in length and can contain letters, digits, underscores (_), and hyphens (-). The name must start with a letter or digit.
valueIntegerYesThe value of the ENUM item.
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes.
  • false: no.

Data structure of the STRUCT type

The following table describes the parameters that are used to define the data of the STRUCT type.

Important
  • The childSpecsDTO and childEnumSpecsDTO that were used in the previous versions of APIs have been phased out. Therefore, no description is provided for these parameters in this section. When you call API operations, you do not need to specify these two parameters. We recommend that you use the dataSpecsList parameter in replacement of the two parameters.
  • If the data of the ARRAY type and the data of the STRUCT type are nested with each other, up to two layers of recursive nesting are supported.
ParameterTypeRequiredDescription
dataTypeStringYesThe type of the data. Set the value to STRUCT.
identifierStringYesThe identifier of the sub-parameter in the struct. The identifier can be up to 50 characters in length and can contain letters, digits, and underscores (_).
Note The identifier cannot be one of the following words: set, get, post, property, event, time, and value.
nameStringYesThe name of the sub-parameter in the struct. The name can be up to 30 characters in length and can contain letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter or digit.
Note The definition of the parameter is the same as the definition of the childName parameter. This parameter is not used.
childDataTypeStringNoThe data type of the sub-parameter in the struct.

Valid values: INT, FLOAT, DOUBLE, TEXT, DATE, ENUM, and BOOL.

childNameStringYesThe name of the sub-parameter in the struct. The name can be up to 30 characters in length and can contain letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter or digit.
dataSpecsObjectNo

If you set the dataType parameter to INT, FLOAT, DOUBLE, TEXT, DATE, or ARRAY, the data specifications are included in the dataSpecs parameter.

Note
  • The dataSpecs parameter applies to all data, excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
dataSpecsListListNoIf you set the dataType parameter to ENUM, BOOL, or STRUCT, the data specifications are included in the dataSpecsList parameter.
Note
  • The dataSpecs parameter applies to all data, excluding the data that is used to define properties, services, events, and parameters.
  • You must specify the dataSpecs or dataSpecsList parameter based on the data type.
customBooleanYesSpecifies whether the TSL feature is a custom feature. Valid values:
  • true: yes
  • false: no

Data structure of the extendConfig parameter

In each property, event, and service, you can use the extendConfig parameter to define the extended information about the TSL model. The extended information indicates the mapping between the connection protocol and the standard TSL model of the device.

Note The configCode parameter indicates the unique identifier that is generated by IoT Platform. The identifier is used to define the extended information about a TSL feature.

If Modbus, OPC UA, or a custom protocol is used as the gateway connection protocol of a device, you can define the extended information about the device. Different types of extended information have different data specifications.

Modbus type

If Modbus is used as the gateway connection protocol of a device, you can define the extended information only about the properties.

Note To fully demonstrate the data structure of the extendConfig parameter, the following example includes all parameters. However, the parameters may vary in actual scenarios. The following table describes these parameters.
{
  "identifier":"extend1",
  "writeFunctionCode":0,
  "writeOnly":0,
  "registerAddress":"0xFE",
  "operateType":"coilStatus",
  "scaling":0.1,
  "pollingTime":1000,
  "trigger":1,
  "bitMask":128,
  "originalDataType":{
     "type":"uint64",
     "specs":{
        "swap":0,
        "reverseRegister":0}
  }
}
ParameterTypeDescription
identifierStringThe identifier of the property. The identifier must be unique in a product.
registerAddressStringThe address of the register. The address must start with 0x. Valid values: 0x0 to 0xFFFF. Example: 0xFE.
operateTypeStringThe type of the operation. Valid values:
  • coilStatus: the status of coils.
  • inputStatus: discrete input.
  • holdingRegister: holding register.
  • inputRegister: input register.
writeFunctionCodeIntegerThe read and write operations. The value varies based on the value of the operateType parameter.
  • coilStatus:
    • 5: read and write (read 0x01, write 0x05).
    • 15: read and write (read 0x01, write 0x0F).
    • 0: read-only (0x01).
    • 6: write-only (0x05).
    • 15: write-only (0x0F).
  • If the operateType parameter is set to inputStatus, the valid value is 0 (read-only 0x02).
  • holdingRegister:
    • 6: read and write (read 0x03, write 0x06).
    • 16: read and write (read 0x03, write 0x10).
    • 0: read-only (0x03).
    • 6: write-only (0x06).
    • 16: write only (0x10).
  • If the operateType parameter is set to inputRegister, the valid value is 0 (read-only 0x04).
writeOnlyIntegerSpecifies whether the operation is write-only. Valid values:
  • 0: not write-only.
    • If the writeFunctionCode parameter is not set to 0, the extendConfig parameter supports read and write operations. If you set the writeOnly parameter to 0, the extendConfig parameter supports read and write operations.
    • If the writeFunctionCode parameter is set to 0, the extendConfig parameter supports only read operations. You must set the writeOnly parameter to 0.
  • 1: write-only.

    If the writeFunctionCode parameter is not set to 0, the extendConfig parameter supports read and write operations. If you set the writeOnly parameter to 1, the extendConfig parameter supports only write operations.

scalingNumberThe scaling factor. The value cannot be 0.

This parameter is unavailable for data of the STRING and BOOLEAN types.

pollingTimeIntegerThe interval of the collection. Unit: ms. You do not need to specify this parameter. The specified collection interval of the device is used.
triggerIntegerThe method to submit data. Valid values: 1 and 2. The value of 1 indicates that data is submitted at a specific time. The value of 2 indicates that data is submitted when changes occur.
bitMaskIntegerThe mask. Valid values: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, and 32768.

This parameter is specific to data of the BOOLEAN type.

originalDataTypeObjectThe description of the original data type.
typeStringThe type of the original data. The type must be one of the following basic data types: INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, STRING, BOOLEAN, and customized (hexadecimal data that is returned in big-endian order).
specsObjectThe parameters that are specific to some data types.
registerCountIntegerThe number of registers.

This parameter is specific to data of the STRING and customized types.

swapIntegerThis parameters is specific to data of all types except for the STRING and customized types.

Specifies whether to switch the high byte and low byte in the register. If so, the first and last 8 bits of the 16-bit integer in the register are swapped. Valid values:

  • 0: The high byte and low byte are not swapped.
  • 1: The high byte and low byte are swapped.
reverseRegisterIntegerThis parameters is specific to data of all types except for the STRING and customized types.
Specifies whether to switch the high byte and low byte in the register. If so, the first and last 16 bits of the 32-bit integer in the register are swapped. Valid values:
  • 0: The high byte and low byte are not swapped.
  • 1: The high byte and low byte are swapped.

OPC UA type

If OPC UA is used as the gateway connection protocol of a device, you can define the extended information about the properties, services, and events.

{
  "identifier":"extend2",
  "displayName":"Action",
  "inputData":[
    {
      "identifier":"xxxx",
      "index":1
    },
    {
      "identifier":"xxxx",
      "index":2 
    }
  ],
  "outputData":[
     {
      "identifier":"xxxx",
      "index":1
    },
    {
      "identifier":"xxxx",
      "index":2
    }
  ]
}
ParameterTypeDescription
identifierStringThe identifier of the property, service, or event. The identifier must be unique in a product.
displayNameStringYou must specify the displayName parameter for a property or an event. You do not need to specify the displayName parameter for a service.
inputDataListThe input data.
outputDataListThe output data.
identifierStringThe identifier of the input data or output data. The identifier must be unique in a product.
indexIntegerThe index. The index must be unique in both the inputData and outputData parameters.

Custom type

If a custom protocol is used as the gateway connection protocol of a device, you can define the extended information about the properties, services, and events.

{
  "identifier":"xxx",
  "customize":{}
}
ParameterTypeDescription
identifierStringThe identifier of the property, service, or event. It must be unique in a product.
customizeObjectThe custom JSON file.

Verify the ThingModelJson parameter

You can use the json-schema file to verify the input parameters in the ThingModelJson parameter.

For more information, see schema.json.

Example of verifying the ThingModelJson parameter

  • Add the following dependency to the Maven project to download the json-schema library:
    <dependency>
        <groupId>com.github.everit-org.json-schema</groupId>
        <artifactId>org.everit.json.schema</artifactId>
        <version>1.11.0</version>
    </dependency>
  • Sample code:
    package com.aliyun.iot.thingmodel;
    
    import java.io.InputStream;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Arrays;
    
    import org.everit.json.schema.Schema;
    import org.everit.json.schema.ValidationException;
    import org.everit.json.schema.loader.SchemaLoader;
    import org.json.JSONObject;
    import org.json.JSONTokener;
    
    /**
     * @author: ***
     * @date: 2020-01-14 15:11
     */
    public class ThingModelJsonValidator {
    
        public static void main(String[] args) throws Exception {
    
            try (InputStream inputStream = new URL("https://iotx-thing-model-schema.oss-ap-southeast-1.aliyuncs.com/schema.json").openStream()) {
                JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
                Schema schema = SchemaLoader.load(rawSchema);
                long start = System.currentTimeMillis();
                JSONObject object = new JSONObject();
                String jsonStr = "{\n"
                        + "\t\t\t\"productKey\": \"a1Q1Yrc****\",\n"
                        + "\t\t\t\"name\": \"Alert event\",\n"
                        + "\t\t\t\"identifier\": \"alarmEvent\",\n"
                        + "\t\t\t\"eventName\": \"Alert event\",\n"
                        + "\t\t\t\"eventType\": \"ALERT_EVENT_TYPE\",\n"
                        + "\t\t\t\"outputData\": [\n"
                        + "\t\t\t\t{\n"
                        + "\t\t\t\t\t\"paraOrder\": 0,\n"
                        + "\t\t\t\t\t\"direction\": \"PARAM_OUTPUT\",\n"
                        + "\t\t\t\t\t\"dataSpecsList\": [\n"
                        + "\t\t\t\t\t\t{\n"
                        + "\t\t\t\t\t\t\t\"dataType\": \"ENUM\",\n"
                        + "\t\t\t\t\t\t\t\"name\": \"Anti-detachment alert\",\n"
                        + "\t\t\t\t\t\t\t\"value\": 0\n"
                        + "\t\t\t\t\t\t},\n"
                        + "\t\t\t\t\t\t{\n"
                        + "\t\t\t\t\t\t\t\"dataType\": \"ENUM\",\n"
                        + "\t\t\t\t\t\t\t\"name\": \"Anti-detachment alert\",\n"
                        + "\t\t\t\t\t\t\t\"value\": 1\n"
                        + "\t\t\t\t\t\t}\n"
                        + "\t\t\t\t\t],\n"
                        + "\t\t\t\t\t\"dataType\": \"ENUM\",\n"
                        + "\t\t\t\t\t\"identifier\": \"alarmType\",\n"
                        + "\t\t\t\t\t\"name\": \"Alert type\",\n"
                        + "\t\t\t\t\t\"index\": 0,\n"
                        + "\t\t\t\t\t\"custom\": true\n"
                        + "\t\t\t\t}\n"
                        + "\t\t\t],\n"
                        + "\t\t\t\"outputParams\": [\n"
                        + "\t\t\t\t{\n"
                        + "\t\t\t\t\t\"index\": 0,\n"
                        + "\t\t\t\t\t\"identifier\": \"alarmType\"\n"
                        + "\t\t\t\t}\n"
                        + "\t\t\t],\n"
                        + "\t\t\t\"custom\": true\n"
                        + "\t\t}";
    
                object.put("properties", new ArrayList<>());
                object.put("services", new ArrayList<>());
                object.put("events", Arrays.asList(com.alibaba.fastjson.JSONObject.parseObject(jsonStr)));
                object.put("productKey", "a1Q1Yrc****");
                schema.validate(object); // throws a ValidationException if this object is invalid
                //}
                System.out.println(System.currentTimeMillis() - start);
            }
            catch (ValidationException exception) {
                System.out.println(exception);
            }
        }
    
    }

Specify the ThingModelJson parameter

The section describes how to use the Visual Studio Code tool to specify the ThingModelJson parameter.

  1. Visit Visual Studio Code official website to download and install the latest version of the Visual Studio Code tool.
  2. Open Visual Studio Code, click the Settings button in the lower left corner, and then select Settings.
  3. On the User Settings tab, choose Extensions > JSON. Click Edit in settings.json under Schemas, and then enter and save the following content.
     "json.schemas": [{
            "fileMatch": ["/.json"],
            "url": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json"
    }]

    Then, you can specify the ThingModelJson parameter as prompted.

    Prompt