After a device submits data by using a custom topic that is attached with the ? _sn=default tag, IoT Platform calls the data parsing script that you submitted to the console to convert the custom format payloads into JSON data for subsequent processing.


  • Parsing data from custom topics is supported only for the China (Shanghai) region.
  • When you configure devices, attach the ? _sn=default tag to custom topics. IoT Platform only parses data from custom topics that are attached with the tag.

    For example, if you need to parse the data that is sent by a device to the /${productKey}/${deviceName}/user/update topic into JSON data, you must define the topic as follows when configuring the device: /${productKey}/${deviceName}/user/update? _sn=default.

    Note When you create a custom topic in the IoT Platform console, define the topic without adding the tag.
  • IoT Platform parses only data submitted by devices to the cloud, and does not parse downstream data sent from the cloud.
  • IoT Platform parses only payloads submitted to the cloud and returns the parsed payloads.
  • Topics in which data resides do not change before or after parsing. For example, a device sends data to the /${productKey}/${deviceName}/user/update topic, and the parsed data still resides in this topic.

Submit scripts for parsing data

  1. Log on to the IoT Platform console.
  2. In the left-side navigation pane, choose Devices > Products.
  3. On the Product page, find the target product and click View.
  4. On the Product Details page, click the Data Parsing tab.
  5. Select a scripting language. In the Edit Script text box, enter the script.

    Only JavaScript (ECMAScript 5), Python 2.7, and PHP 7.2 are supported.

    Define one of the following functions to be called in the script:

    • JavaScript (ECMAScript 5): transformPayload()
    • Python 2.7: Transform_payload ()
    • PHP 7.2: transformPayload()

    For information about complete sample code, see JavaScript example, Python example, and PHP example.

    Note If the Data Format parameter of the product is set to Custom, you also need to write a script for parsing TSL data. For information about how to write a script for parsing TSL data, see Example for parsing TSL data.
  6. Test the script.
    1. On the Input Simulation tab, set the Simulation Type parameter to Custom and select a device and a topic.
    2. Enter simulated data that devices submit and click Run.
  7. After you confirm that the script is valid, click Submit to submit the script to the IoT Platform console.