This topic describes how to write scripts to parse Thing Specification Language (TSL) data for products whose Data Format is Custom. A sample script is provided for parsing upstream and downstream property data.
Step 1: Submit a script
Step 2: Test the script online
After the script is edited, on the Input Simulation tab, select Simulation Type, and enter test script and simulation data to test the script.
- Parse the property data reported by the device.
Set the simulation type to Upstreamed Device Data, enter the following simulation data, and then click Run.
0x00002233441232013fa00000
The data parsing engine converts the pass-through data to JSON data according to the rules defined in the script.
Click Parsing Results to view the parsed data.
{ "method": "thing.event.property.post", "id": "2241348", "params": { "prop_float": 1.25, "prop_int16": 4658, "prop_bool": 1 }, "version": "1.0" }
- Parse the response returned by IoT Platform.
Set the simulation type to Received Device Data, enter the following JSON data, and then click Run.
{ "id": "12345", "version": "1.0", "code": 200, "method": "thing.event.property.post", "data": {} }
The data parsing engine converts the JSON data to the following data.
0x0200003039c8
- Parse the data for setting properties sent by IoT Platform.
Set the simulation type to Received Device Data, enter the following JSON data, and then click Run.
{ "method": "thing.service.property.set", "id": "12345", "version": "1.0", "params": { "prop_float": 123.452, "prop_int16": 333, "prop_bool": 1 } }
The data parsing engine converts the JSON data to the following data.
0x0100003039014d0142f6e76d
- Parse the result data returned by the device after setting properties.
Set the simulation type to Upstreamed Device Data, enter the following simulation data, and then click Run.
0x0300223344c8
The data parsing engine converts the pass-through data to the following JSON data.
{ "code": "200", "data": {}, "id": "2241348", "version": "1.0" }
Step 3: Submit the script
After you confirm that the script parses data correctly, click Submit to submit the script to the backend system of IoT Platform.

Step 4: Use a physical device for debugging
Before you use the script, use a real device to communicate with IoT Platform. Make sure that IoT Platform can call the script and parse upstream and downstream data.
- Test upstream property data.
- Use the property data reported by the device, for example,
0x00002233441232013fa00000
. - In the IoT Platform console, choose .
- Find the target device and click View. On the Status tab of the Device Details page, check whether the corresponding property data exists.
- Use the property data reported by the device, for example,
- Test downstream property data.
- In the IoT Platform console, choose .
- Select the product and device to debug. Select Debug Physical Device. Set the debug feature to the identifier of the property, for example, prop_int16.
Set the method to Set. Enter the following data and click Dispatch Command.
{ "method": "thing.service.property.set", "id": "12345", "version": "1.0", "params": { "prop_float": 123.452, "prop_int16": 333, "prop_bool": 1 } }
- Check whether the device receives the data for setting properties.
- On the Status tab of the Device Details page for the device, check whether the device has reported the current property data.
Related topics
- For more information about JavaScript (ECMAScript 5) script templates and examples, see JavaScript example.
- For more information about PHP 7.2 script templates and examples, see Python example.
- For more information about Python 2.7 script templates and examples, see PHP example.
- For more information about the data parsing process, see What is data parsing?.
- For more information about how to parse data involving custom topics, see Overview.