# How can i populated value to JSON payload

**URL:** <https://discourse.nodered.org/t/how-can-i-populated-value-to-json-payload/75818>\
**Category:** General\
**Tags:** function-node\
**Created:** [27 February 2023 15:59 UTC](https://discourse.nodered.org/t/how-can-i-populated-value-to-json-payload/75818 "2023-02-27T15:59:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rchandrashekar53](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rchandrashekar53/32/60423_2.png) [@rchandrashekar53](https://discourse.nodered.org/u/rchandrashekar53)\
**Post date:** [27 February 2023 15:59 UTC](https://discourse.nodered.org/t/how-can-i-populated-value-to-json-payload/75818/1 "2023-02-27T15:59:04Z")

</div>

Hi,  
i do have a function node where i build a JSON message based on the set points.

However as you observer i do have a parent node "01" this refers to the data packet which i receive from the

```auto
global.get("currentDataPacket")

```

which will increment and give a current data packet number.  
Is there a way how i can send

```auto
global.get("currentDataPacket")

```

value instead  
`"01"`?

```auto
msg.payload =
{
    "state": {
        "response": {
            "home": {
                "01": {
                    "temperature": global.get("currentTemp"),
                    "humidity": global.get("currentHumidty")
                }
            }
        }    
    }    
}

```

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [27 February 2023 16:12 UTC](https://discourse.nodered.org/t/how-can-i-populated-value-to-json-payload/75818/2 "2023-02-27T16:12:39Z")

</div>

```auto
msg.payload =
{
    "state": {
        "response": {
            "home": {
                 [global.get("currentDataPacket")]: {
                    "temperature": global.get("currentTemp"),
                    "humidity": global.get("currentHumidty")
                }
            }
        }    
    }    
}

```

---

<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:** [27 February 2023 16:15 UTC](https://discourse.nodered.org/t/how-can-i-populated-value-to-json-payload/75818/3 "2023-02-27T16:15:40Z")

</div>

> [@rchandrashekar53](#):
>
> i build a JSON message

In fact that is not JSON, JSON is always a string. You are creating 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:** [28 April 2023 16:16 UTC](https://discourse.nodered.org/t/how-can-i-populated-value-to-json-payload/75818/4 "2023-04-28T16:16:32Z")

</div>

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