json 首先安装json-db-node-red并将其导入Node RED。这将设置订单服务器。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json 首先安装json-db-node-red并将其导入Node RED。这将设置订单服务器。相关的知识,希望对你有一定的参考价值。

[
    {
        "id": "ac56ee52.2639b",
        "type": "http in",
        "z": "fa08be7b.70af3",
        "name": "Is Ready HTTP Request",
        "url": "/is-ready",
        "method": "get",
        "swaggerDoc": "",
        "x": 236,
        "y": 164,
        "wires": [
            [
                "c38bbd09.d87bc"
            ]
        ]
    },
    {
        "id": "b54aec01.16637",
        "type": "DataIn",
        "z": "fa08be7b.70af3",
        "collection": "f3fbf1a7.b487f",
        "name": "Units",
        "update": false,
        "path": "/units",
        "x": 2559,
        "y": 666,
        "wires": []
    },
    {
        "id": "b22d7556.755738",
        "type": "DataOut",
        "z": "fa08be7b.70af3",
        "collection": "f3fbf1a7.b487f",
        "name": "Units",
        "path": "/units",
        "error": true,
        "x": 1161,
        "y": 327,
        "wires": [
            [
                "d7849891.629928"
            ]
        ]
    },
    {
        "id": "f8c241fc.7ce78",
        "type": "http in",
        "z": "fa08be7b.70af3",
        "name": "Activate HTTP Request",
        "url": "/activate",
        "method": "get",
        "swaggerDoc": "",
        "x": 233,
        "y": 287,
        "wires": [
            [
                "2424260a.d32a2a"
            ]
        ]
    },
    {
        "id": "4674bdf3.6c56c4",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Parse Unit #",
        "func": "// msg.payload = {\"enabled\": msg.payload.filter(function(item) {\n//     return item === msg.req.param.unit;\n// })}\nmsg.unit = parseInt(msg.unit);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 998,
        "y": 327,
        "wires": [
            [
                "b22d7556.755738"
            ]
        ]
    },
    {
        "id": "cedaf8f3.d9c1b8",
        "type": "inject",
        "z": "fa08be7b.70af3",
        "name": "Trigger Is Ready",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 230,
        "y": 681,
        "wires": [
            [
                "4cf42fae.2dd58"
            ]
        ]
    },
    {
        "id": "4cf42fae.2dd58",
        "type": "http request",
        "z": "fa08be7b.70af3",
        "name": "Simulate \"Is Ready\" Request",
        "method": "GET",
        "ret": "obj",
        "url": "http://127.0.0.1:1880/is-ready?unit=1",
        "tls": "",
        "x": 533,
        "y": 680,
        "wires": [
            []
        ]
    },
    {
        "id": "e4c32d74.12ec3",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Check if active",
        "func": "msg.payload = msg.units.filter(function(item) {\n    return item === msg.unit;\n}).length > 0;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1582,
        "y": 328,
        "wires": [
            [
                "4368172.75d65e8"
            ]
        ]
    },
    {
        "id": "2c1a6d2b.e19dd2",
        "type": "http response",
        "z": "fa08be7b.70af3",
        "name": "",
        "x": 3425,
        "y": 485,
        "wires": []
    },
    {
        "id": "5e20c44a.feed4c",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Build Is Ready Response",
        "func": "msg.payload = {\"active\": msg.payload};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2316,
        "y": 205,
        "wires": [
            [
                "2c1a6d2b.e19dd2",
                "7501d98c.59e5a8",
                "bbf2e2e6.bbbfc"
            ]
        ]
    },
    {
        "id": "a2689ca6.a8df3",
        "type": "change",
        "z": "fa08be7b.70af3",
        "name": "Store Unit #",
        "rules": [
            {
                "t": "move",
                "p": "payload.unit",
                "pt": "msg",
                "to": "unit",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 813,
        "y": 327,
        "wires": [
            [
                "4674bdf3.6c56c4"
            ]
        ]
    },
    {
        "id": "c38bbd09.d87bc",
        "type": "change",
        "z": "fa08be7b.70af3",
        "name": "Set Is Ready Intent",
        "rules": [
            {
                "t": "set",
                "p": "intent",
                "pt": "msg",
                "to": "is-ready",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 527,
        "y": 243,
        "wires": [
            [
                "a2689ca6.a8df3"
            ]
        ]
    },
    {
        "id": "2424260a.d32a2a",
        "type": "change",
        "z": "fa08be7b.70af3",
        "name": "Set Activate Intent",
        "rules": [
            {
                "t": "set",
                "p": "intent",
                "pt": "msg",
                "to": "activate",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 528,
        "y": 326,
        "wires": [
            [
                "a2689ca6.a8df3"
            ]
        ]
    },
    {
        "id": "7d189dd5.98e8a4",
        "type": "comment",
        "z": "fa08be7b.70af3",
        "name": "Activate Node",
        "info": "",
        "x": 201,
        "y": 244,
        "wires": []
    },
    {
        "id": "8a53585c.933088",
        "type": "comment",
        "z": "fa08be7b.70af3",
        "name": "Is Ready Node",
        "info": "",
        "x": 216,
        "y": 117,
        "wires": []
    },
    {
        "id": "d7849891.629928",
        "type": "change",
        "z": "fa08be7b.70af3",
        "name": "Store Units Status",
        "rules": [
            {
                "t": "set",
                "p": "units",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1353,
        "y": 327,
        "wires": [
            [
                "e4c32d74.12ec3"
            ]
        ]
    },
    {
        "id": "4368172.75d65e8",
        "type": "switch",
        "z": "fa08be7b.70af3",
        "name": "Check Intent",
        "property": "intent",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "is-ready",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "activate",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "deactivate",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 3,
        "x": 1814,
        "y": 327,
        "wires": [
            [
                "5e20c44a.feed4c"
            ],
            [
                "9eab7c63.80543"
            ],
            [
                "a53cb89.fa85e48"
            ]
        ]
    },
    {
        "id": "7501d98c.59e5a8",
        "type": "debug",
        "z": "fa08be7b.70af3",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "false",
        "x": 3444,
        "y": 421,
        "wires": []
    },
    {
        "id": "9eab7c63.80543",
        "type": "switch",
        "z": "fa08be7b.70af3",
        "name": "Is Active",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 2043,
        "y": 519,
        "wires": [
            [
                "1f5e0a59.3cf696"
            ],
            [
                "e0142914.7a7168"
            ]
        ]
    },
    {
        "id": "e0142914.7a7168",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Activate Unit",
        "func": "msg.units.push(msg.unit);\nmsg.payload = msg.units;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2275,
        "y": 585,
        "wires": [
            [
                "b54aec01.16637",
                "2da1f7bf.8b9148"
            ]
        ]
    },
    {
        "id": "d6bf40d3.52ea",
        "type": "comment",
        "z": "fa08be7b.70af3",
        "name": "Is Ready Test Trigger",
        "info": "",
        "x": 218,
        "y": 635,
        "wires": []
    },
    {
        "id": "1f5e0a59.3cf696",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Set Already Active Response",
        "func": "msg.payload = {\"msg\": \"Unit \" + msg.unit + \" is already active.\"};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2321,
        "y": 437,
        "wires": [
            [
                "2c1a6d2b.e19dd2",
                "7501d98c.59e5a8",
                "bbf2e2e6.bbbfc"
            ]
        ]
    },
    {
        "id": "2da1f7bf.8b9148",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Set Now Active Response",
        "func": "\nmsg.payload = {\"msg\": \"Unit \" + msg.unit + \" is now active.\"};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2615,
        "y": 510,
        "wires": [
            [
                "2c1a6d2b.e19dd2",
                "7501d98c.59e5a8",
                "bbf2e2e6.bbbfc"
            ]
        ]
    },
    {
        "id": "50b2d08a.65f72",
        "type": "inject",
        "z": "fa08be7b.70af3",
        "name": "Trigger Activate",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 229,
        "y": 800,
        "wires": [
            [
                "21401e08.b56ba2"
            ]
        ]
    },
    {
        "id": "21401e08.b56ba2",
        "type": "http request",
        "z": "fa08be7b.70af3",
        "name": "Simulate \"Activate\" Request",
        "method": "GET",
        "ret": "txt",
        "url": "http://127.0.0.1:1880/activate?unit=1",
        "tls": "",
        "x": 533,
        "y": 799,
        "wires": [
            []
        ]
    },
    {
        "id": "5f40df6a.ca78b",
        "type": "comment",
        "z": "fa08be7b.70af3",
        "name": "Activate Test Trigger",
        "info": "",
        "x": 217,
        "y": 760,
        "wires": []
    },
    {
        "id": "de723d45.bb08b",
        "type": "http in",
        "z": "fa08be7b.70af3",
        "name": "Deactivate HTTP Request",
        "url": "/deactivate",
        "method": "get",
        "swaggerDoc": "",
        "x": 246,
        "y": 477,
        "wires": [
            [
                "62144c68.64b2b4"
            ]
        ]
    },
    {
        "id": "936d21dc.82921",
        "type": "comment",
        "z": "fa08be7b.70af3",
        "name": "Deactivate Node",
        "info": "",
        "x": 215,
        "y": 433,
        "wires": []
    },
    {
        "id": "62144c68.64b2b4",
        "type": "change",
        "z": "fa08be7b.70af3",
        "name": "Set Deactivate Intent",
        "rules": [
            {
                "t": "set",
                "p": "intent",
                "pt": "msg",
                "to": "deactivate",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 539,
        "y": 419,
        "wires": [
            [
                "a2689ca6.a8df3"
            ]
        ]
    },
    {
        "id": "a53cb89.fa85e48",
        "type": "switch",
        "z": "fa08be7b.70af3",
        "name": "Is Active",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 2044,
        "y": 879,
        "wires": [
            [
                "709ddd90.8b0e24"
            ],
            [
                "4359f25d.f3e18c"
            ]
        ]
    },
    {
        "id": "709ddd90.8b0e24",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Deactivate Unit",
        "func": "msg.units.splice(msg.units.indexOf(msg.unit), 1);\nmsg.payload = msg.units;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2286,
        "y": 805,
        "wires": [
            [
                "b54aec01.16637",
                "d24fc008.5a8c4"
            ]
        ]
    },
    {
        "id": "4359f25d.f3e18c",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Set Already Inactive Response",
        "func": "msg.payload = {\"msg\": \"Unit \" + msg.unit + \" is already inactive.\"};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2322,
        "y": 956,
        "wires": [
            [
                "2c1a6d2b.e19dd2",
                "7501d98c.59e5a8",
                "bbf2e2e6.bbbfc"
            ]
        ]
    },
    {
        "id": "d24fc008.5a8c4",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Set Now Inactive Response",
        "func": "\nmsg.payload = {\"msg\": \"Unit \" + msg.unit + \" is now inactive.\"};\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 2594.5000381469727,
        "y": 819.0000133514404,
        "wires": [
            [
                "2c1a6d2b.e19dd2",
                "7501d98c.59e5a8",
                "bbf2e2e6.bbbfc"
            ]
        ]
    },
    {
        "id": "66dfab0a.2d7c14",
        "type": "inject",
        "z": "fa08be7b.70af3",
        "name": "Trigger Deactivate",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 241,
        "y": 928,
        "wires": [
            [
                "4312790b.ab04e8"
            ]
        ]
    },
    {
        "id": "4312790b.ab04e8",
        "type": "http request",
        "z": "fa08be7b.70af3",
        "name": "Simulate \"Deactivate\" Request",
        "method": "GET",
        "ret": "obj",
        "url": "http://127.0.0.1:1880/deactivate?unit=1",
        "tls": "",
        "x": 552,
        "y": 925,
        "wires": [
            []
        ]
    },
    {
        "id": "2eadd261.8872ae",
        "type": "comment",
        "z": "fa08be7b.70af3",
        "name": "Deactivate Test Trigger",
        "info": "",
        "x": 227,
        "y": 888,
        "wires": []
    },
    {
        "id": "447844c7.70154c",
        "type": "inject",
        "z": "fa08be7b.70af3",
        "name": "Init DB",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 210,
        "y": 1033,
        "wires": [
            [
                "50fcb157.be574"
            ]
        ]
    },
    {
        "id": "c1a2eb4b.759818",
        "type": "DataIn",
        "z": "fa08be7b.70af3",
        "collection": "f3fbf1a7.b487f",
        "name": "Create Units",
        "update": false,
        "path": "/units",
        "x": 624,
        "y": 1032,
        "wires": []
    },
    {
        "id": "50fcb157.be574",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Blank Array Payload",
        "func": "msg.payload = [];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 406,
        "y": 1032,
        "wires": [
            [
                "c1a2eb4b.759818"
            ]
        ]
    },
    {
        "id": "acd930f7.d3ecc",
        "type": "websocket out",
        "z": "fa08be7b.70af3",
        "name": "WS",
        "server": "",
        "client": "a5a41bdf.4b44a8",
        "x": 3426.666666666666,
        "y": 553.3333333333333,
        "wires": []
    },
    {
        "id": "352112c6.dac67e",
        "type": "websocket in",
        "z": "fa08be7b.70af3",
        "name": "Do Action",
        "server": "556fc048.52894",
        "client": "",
        "x": 179,
        "y": 561,
        "wires": [
            [
                "145a9c7.441c564"
            ]
        ]
    },
    {
        "id": "145a9c7.441c564",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Parse",
        "func": "msg.payload = JSON.parse(msg.payload);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 332,
        "y": 559,
        "wires": [
            [
                "c04b1619.b5dee8"
            ]
        ]
    },
    {
        "id": "c04b1619.b5dee8",
        "type": "switch",
        "z": "fa08be7b.70af3",
        "name": "",
        "property": "payload.intent",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "status",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "activate",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "deactivate",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 3,
        "x": 464,
        "y": 558,
        "wires": [
            [
                "c38bbd09.d87bc"
            ],
            [
                "2424260a.d32a2a"
            ],
            [
                "62144c68.64b2b4"
            ]
        ]
    },
    {
        "id": "bbf2e2e6.bbbfc",
        "type": "function",
        "z": "fa08be7b.70af3",
        "name": "Stringify",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 3261,
        "y": 624,
        "wires": [
            [
                "acd930f7.d3ecc"
            ]
        ]
    },
    {
        "id": "f3fbf1a7.b487f",
        "type": "json-db-collection",
        "z": "",
        "name": "Units",
        "collection": "units",
        "save": true
    },
    {
        "id": "a5a41bdf.4b44a8",
        "type": "websocket-client",
        "z": "",
        "path": "ws://127.0.0.1:1880/ws",
        "wholemsg": "false"
    },
    {
        "id": "556fc048.52894",
        "type": "websocket-listener",
        "z": "",
        "path": "/ws",
        "wholemsg": "false"
    }
]

以上是关于json 首先安装json-db-node-red并将其导入Node RED。这将设置订单服务器。的主要内容,如果未能解决你的问题,请参考以下文章

json-server的安装及使用

mac电脑sublime text3安装pretty json插件

Visual Studio中如何安装使用Newtonsoft Json

Visual Studio中如何安装使用Newtonsoft Json

json server的简单使用(附:使用nodejs快速搭建本地服务器)

要导入 Sass 文件,首先需要安装 node-sass