本文介绍物联网平台为产品定义物模型遇到的相关问题及解决方法。
批量导入物模型,TSL检验失败怎么办?
问题现象:如下图所示,导入物模型过程,出现校验失败现象。

解决方法:
- ①:对物模型文件进行JSON格式化校验,完成修正。
- ②:单击下载查看,获取errors.txt文件,定位问题及原因,完成修正。
errors.txt文件的详细说明,请参见如下示例。
物模型文件示例:
{ "schema":"https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json", "profile":{ "productKey":"a1Jk***" }, "services":[], "properties": 1, "events": [], "functionBlockId": "模块mtest", "functionBlockName": "自定义模块1" }
下载的errors.txt文件:
[ { "path": [ "properties" ], "property": "instance.properties", "message": "is not of a type(s) array", "schema": { "type": "array", "items": { "$ref": "#/definitions/propertyDefinition" } }, "instance": 1, "name": "type", "argument": [ "array" ], "stack": "instance.properties is not of a type(s) array" }, { "path": [ "functionBlockId" ], "property": "instance.functionBlockId", "message": "does not match pattern \"^[_a-zA-Z0-9]{1,30}$\"", "schema": { "type": "string", "pattern": "^[_a-zA-Z0-9]{1,30}$" }, "instance": "模块mtest", "name": "pattern", "argument": "^[_a-zA-Z0-9]{1,30}$", "stack": "instance.functionBlockId does not match pattern \"^[_a-zA-Z0-9]{1,30}$\"" } ]
参数 说明 path 校验后,出错的路径。本文示例校验出2处错误: // properties配置错误,不是数组 "path": [ "properties" ] // functionBlockId含有中文 "path": [ "functionBlockId" ]
property path下不合规则的具体对象。 例如
"path": ["functionBlockId" ]
中的instance.functionBlockId
。message 具体的错误提示信息。 例如
"path": ["functionBlockId" ]
中,提示property的错误为does not match pattern \"^[_a-zA-Z0-9]{1,30}$\"
。schema 校验的规则名称及对应内容。 例如
"path": ["functionBlockId" ]
中的规则type
和pattern
。有关规则定义的详细内容,请参见schama。
instance 校验的具体对象。 例如
"path": ["functionBlockId" ]
中,校验物模型文件中"functionBlockId": "模块mtest"
的内容。name 校验未通过规则的名称。 例如
"path": ["functionBlockId" ]
中,校验对象模块mtest
不符合规则pattern
。argument 校验未通过规则的内容。 例如
"path": ["functionBlockId" ]
中,不符合规则pattern
的定义为^[_a-zA-Z0-9]{1,30}$
。stack 堆栈信息。由property和message内容组合的完整错误提示信息。
更多信息,请参见校验工具jsonschema的说明。
在文档使用中是否遇到以下问题
更多建议
匿名提交