hunl0613 发表于 2024-3-1 22:18:42

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

本帖最后由 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:}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\nreturn msg;",
      "outputs": 1,
      "timeout": 0,
      "noerr": 0,
      "initialize": "",
      "finalize": "",
      "libs": [],
      "x": 880,
      "y": 60,
      "wires": [
            [
                "21a0a4d1c693f9f7"
            ]
      ]
    }
]



请问上面node-red的代码出现错误"Unexpected token S in JSON at position 1",不知道错误在那里,请教各位大神如何更改
页: [1]
查看完整版本: JSON处理代码出现错误"Unexpected token S in JSON at position 1"