# Creating JSON Object with Buttons, Sliders and Text Inputs

**URL:** <https://discourse.nodered.org/t/creating-json-object-with-buttons-sliders-and-text-inputs/66750>\
**Category:** Industrial\
**Created:** [22 August 2022 11:37 UTC](https://discourse.nodered.org/t/creating-json-object-with-buttons-sliders-and-text-inputs/66750 "2022-08-22T11:37:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihaila-andreas](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@mihaila-andreas](https://discourse.nodered.org/u/mihaila-andreas)\
**Post date:** [22 August 2022 11:37 UTC](https://discourse.nodered.org/t/creating-json-object-with-buttons-sliders-and-text-inputs/66750/1 "2022-08-22T11:37:02Z")

</div>

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.

```auto
[
    {
        "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"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 August 2022 13:19 UTC](https://discourse.nodered.org/t/creating-json-object-with-buttons-sliders-and-text-inputs/66750/2 "2022-08-22T13:19:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 October 2022 13:20 UTC](https://discourse.nodered.org/t/creating-json-object-with-buttons-sliders-and-text-inputs/66750/3 "2022-10-21T13:20:36Z")

</div>

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