Creating JSON Object with Buttons, Sliders and Text Inputs

Hi there,

I was wondering how I can create a JSON Object wit some dynamic inputs (buttons, sliders, and texts).

I was trying to solve that in order to use a function to build the Object but unfortunately it does not work.

Does anybody have got created something like that? I would like to update this object every seconds and send it via MQTT to a broker (this is not an issue for me).

I am sharing my flow with you here .. it might be easily ridiculous for some of you but I am not that familiar at the moment with that.

[
    {
        "id": "b5aa666fa2133ad4",
        "type": "function",
        "z": "0b972752ccc7083a",
        "name": "Building JSON Object",
        "func": "var JSONDataOut = {} \n\nJSONDataOut = {\n    \nStart: payload_1, \nStop: payload.Stop,\nReset: payload.Reset,\nEStop: payload.EStop,\nManualMode: payload.ManualMode,\nAutoMode: payload.AutoMode\n\n}\n\nmsg.payload = JSONDataOut;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 595,
        "y": 300,
        "wires": [
            [
                "0b505a148f147b8f"
            ]
        ]
    }
]

You are referencing data such as payload.Stop. That should be msg.payload.Stop

It isn't JSON data, JSON is always a string. It is a javascript object.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.