What is message parsing

Updated at:

The standard data format for device messages in IoT Platform is Alink JSON. Devices with limited resources, low configurations, or network traffic constraints may not be able to construct JSON data directly. Instead, these devices can pass raw data through to IoT Platform. The platform provides a message parsing feature that converts message data between a custom device format and the JSON format based on a script you submit.

Background information

Message parsing supports two types of messages:

  • Uplink messages from custom topics: Parses the payload from a custom format into the JSON format. The device sends this data to the IoT Platform cloud through a custom topic.

  • Uplink and downlink messages for Thing model topics: Converts Thing model data from a custom format to the Alink JSON format for uplink messages, and converts data from the Alink JSON format to a custom format for downlink messages.

Custom topic message parsing

When a device publishes a message through a custom topic that contains the parsing mark (?_sn=default), IoT Platform receives the message and calls the message parsing script you submitted in the IoT Platform console. The script parses the payload of the custom-format data into a JSON structure before further processing.

Data parsing flowchart:

数据解析流程

End-to-end flowchart for a device reporting data (uplink data) to a custom topic:

custom topic data parse

For information about how to write a message parsing script for a custom topic, see:

Thing model message parsing

When devices of a product communicate with the cloud using Thing model data, data conversion is required if the product's Data Format is set to Pass-through/Custom. IoT Platform calls the message parsing script you submit. The script converts uplink messages to the standard Alink JSON format and downlink messages to the device's custom data format.

When IoT Platform receives data from a device, it runs the parsing script to convert the pass-through data into the Alink JSON format for further processing. Before IoT Platform sends a message to a device, it also runs the script to convert the message data into the device's custom format.

Data parsing flowchart:

物模型数据解析

End-to-end flowchart for a device reporting properties or events in pass-through format (uplink data):

设备透传数据

End-to-end flowchart for invoking a device service or setting a property (downlink data):

Alink 数据传输

For examples of how to write a data parsing script for a Thing model, see:

If the device is a LoRaWAN node, see LoRaWAN device message parsing.

If the submitted script fails to parse message data, see Troubleshooting.