『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 137|回复: 0

[求助] JSON处理代码出现错误"Unexpected token S in JSON at position 1"

[复制链接]

7

主题

15

帖子

82

积分

注册会员

Rank: 2

积分
82
金钱
67
HASS币
0
发表于 2024-3-1 22:18:42 | 显示全部楼层 |阅读模式
本帖最后由 hunl0613 于 2024-3-1 22:23 编辑

[
    {
        "id": "1c3b287274c05b34",
        "type": "tab",
        "label": "流程 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "bd8678c06758f005",
        "type": "json",
        "z": "1c3b287274c05b34",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": true,
        "x": 570,
        "y": 60,
        "wires": [
            [
                "efdb513c508bbd47"
            ]
        ]
    },
    {
        "id": "8e0ae9647dc89919",
        "type": "function",
        "z": "1c3b287274c05b34",
        "name": "function 1",
        "func": "msg.payload=\"123{Status:[0,1,80,42.000,0,0,1,0,0,0,14,0,0,0,15,0,0,0,0,0,38,0,0,0,0,13,18,0,16,12,1,0,0,0,0,0]}321\"\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 260,
        "y": 60,
        "wires": [
            [
                "116a399c4c79bccd"
            ]
        ]
    },
    {
        "id": "3a9962a5af412c65",
        "type": "inject",
        "z": "1c3b287274c05b34",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 110,
        "y": 60,
        "wires": [
            [
                "8e0ae9647dc89919"
            ]
        ]
    },
    {
        "id": "21a0a4d1c693f9f7",
        "type": "debug",
        "z": "1c3b287274c05b34",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1020,
        "y": 60,
        "wires": []
    },
    {
        "id": "efdb513c508bbd47",
        "type": "function",
        "z": "1c3b287274c05b34",
        "name": "function 3",
        "func": "msg.payload=msg.payload.Status\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 720,
        "y": 60,
        "wires": [
            [
                "9237b25776e9dc26"
            ]
        ]
    },
    {
        "id": "116a399c4c79bccd",
        "type": "function",
        "z": "1c3b287274c05b34",
        "name": "function 4",
        "func": "var spl = msg.payload;\nvar zLen = spl.indexOf(\"{\");\nvar yLen = spl.indexOf(\"}\")+1;\nmsg.payload = spl.substring(zLen, yLen);\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 60,
        "wires": [
            [
                "bd8678c06758f005"
            ]
        ]
    },
    {
        "id": "9237b25776e9dc26",
        "type": "function",
        "z": "1c3b287274c05b34",
        "name": "function 5",
        "func": "msg.payload=msg.payload[3]\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 880,
        "y": 60,
        "wires": [
            [
                "21a0a4d1c693f9f7"
            ]
        ]
    }
]

flows.rar (756 Bytes, 下载次数: 0)

请问上面node-red的代码出现错误"Unexpected token S in JSON at position 1",不知道错误在那里,请教各位大神如何更改
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-16 09:38 , Processed in 1.443183 second(s), 25 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表