在物联网业务场景中,资源受限或配置较低的设备,不适合直接构造JSON数据与物联网平台通信,可将原数据直接透传到物联网平台。物联网平台会调用您提交的数据解析脚本,将设备上行数据解析为物联网平台定义的标准格式(Alink JSON),再进行业务处理。
背景信息
数据解析流程图如下所示。

本文以环境数据采集设备为例,为您介绍数据解析具体操作步骤。
设备端接入物联网平台
编写数据解析脚本
在物联网平台控制台,编辑、提交脚本,并模拟数据解析。
脚本提交后,可运行设备端SDK脚本调试验证。设备端再向物联网平台上报数据时,物联网平台会调用脚本进行数据解析。解析后的数据将显示在设备对应设备详情页的 页签下。

附:物模型TSL
{
"schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
"profile": {
"version": "1.0",
"productKey": "g4***"
},
"properties": [
{
"identifier": "lightLux",
"name": "光照强度",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
},
{
"identifier": "PM25",
"name": "PM25",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "1000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"accessMode": "rw",
"desc": "HCHOValue",
"required": false,
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"accessMode": "rw",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "temperature",
"name": "温度",
"accessMode": "rw",
"desc": "电机工作温度",
"required": false,
"dataType": {
"type": "float",
"specs": {
"min": "-10",
"max": "50",
"unit": "℃",
"step": "0.1"
}
}
}
],
"events": [
{
"identifier": "post",
"name": "post",
"type": "info",
"required": true,
"desc": "属性上报",
"method": "thing.event.property.post",
"outputData": [
{
"identifier": "lightLux",
"name": "光照强度",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
},
{
"identifier": "PM25",
"name": "PM25",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "1000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "temperature",
"name": "温度",
"dataType": {
"type": "float",
"specs": {
"min": "-10",
"max": "50",
"unit": "℃",
"step": "0.1"
}
}
}
]
}
],
"services": [
{
"identifier": "set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置",
"method": "thing.service.property.set",
"inputData": [
{
"identifier": "lightLux",
"name": "光照强度",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
},
{
"identifier": "PM25",
"name": "PM25",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "1000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "temperature",
"name": "温度",
"dataType": {
"type": "float",
"specs": {
"min": "-10",
"max": "50",
"unit": "℃",
"step": "0.1"
}
}
}
],
"outputData": []
},
{
"identifier": "get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取",
"method": "thing.service.property.get",
"inputData": [
"lightLux",
"PM25",
"hcho",
"co2",
"humidity",
"temperature"
],
"outputData": [
{
"identifier": "lightLux",
"name": "光照强度",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10000",
"unit": "Lux",
"unitName": "照度",
"step": "0.1"
}
}
},
{
"identifier": "PM25",
"name": "PM25",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "1000",
"unit": "μg/m³",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "hcho",
"name": "甲醛",
"dataType": {
"type": "float",
"specs": {
"min": "0",
"max": "10",
"unit": "ppm",
"unitName": "百万分率",
"step": "0.1"
}
}
},
{
"identifier": "co2",
"name": "二氧化碳",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "10000",
"unit": "mg/m³",
"unitName": "毫克每立方米",
"step": "1"
}
}
},
{
"identifier": "humidity",
"name": "湿度",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "1"
}
}
},
{
"identifier": "temperature",
"name": "温度",
"dataType": {
"type": "float",
"specs": {
"min": "-10",
"max": "50",
"unit": "℃",
"step": "0.1"
}
}
}
]
}
]
}