A device submits data in a custom format to a custom topic that has the parsing tag
?_sn=default
. After IoT Platform receives the data, IoT Platform calls a data parsing script,
converts the data in a custom format to a JSON structure, and then forwards the JSON-formatted
data to subsequent business systems. This topic describes how to write a script to
parse data in a custom format and submit the script in the IoT Platform console.
Usage notes and limits
- IoT Platform allows you to parse data from custom topics only in the China (Shanghai) and Japan (Tokyo) regions.
- IoT Platform parses only data from custom topics that is submitted by devices that are connected over Message Queuing Telemetry Transport (MQTT).
- IoT Platform parses only data that is submitted by devices to the cloud, and does not parse downstream data that is sent from the cloud.
- IoT Platform parses the payloads of data that is submitted to the cloud and returns the payloads of the parsed data.
- When IoT Platform parses data, the parsed data resides in the same topic. For example,
a device sends data to the
/${productKey}/${deviceName}/user/update
topic, and the parsed data resides in this topic.
Parsing tag
When you configure a device to publish messages to a custom topic, attach the parsing
tag ?_sn=default
to the custom topic.
For example, if you want to parse the data that is sent by a device to the /${productKey}/${deviceName}/user/update
topic into JSON-formatted data, you must specify the following topic when you configure
the device: /${productKey}/${deviceName}/user/update?_sn=default
.
Procedure
Optional: Update the data parsing script
After you submit the data parsing script, go to the Data Parsing tab. On the Data Parsing tab, modify or delete script code and then re-submit the script.
References
- For information about the data parsing process, see What is data parsing?.
- For more information about how to parse TSL data in a custom format, see Submit a data parsing script.
- For information about the API operations that are used to send messages to devices, see Use of TSL models and Messaging.