# Help with deconstrucing a message

**URL:** <https://discourse.nodered.org/t/help-with-deconstrucing-a-message/15450>\
**Category:** General\
**Created:** [12 September 2019 05:24 UTC](https://discourse.nodered.org/t/help-with-deconstrucing-a-message/15450 "2019-09-12T05:24:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 September 2019 05:24 UTC](https://discourse.nodered.org/t/help-with-deconstrucing-a-message/15450/1 "2019-09-12T05:24:32Z")

</div>

I found the original problem which was stopping me, but there are still things I am not getting.

This is _the_ message received which I want to dissect.

`{"topic":null,"host":null,"_msgid":"a2c057de.049818","_topic":null,"payload":{"Who":"TimePi","device":"UpLink","UpLink":"Online"},"_event":"node:97bcd5bc.1a76e8","condition":"Online"}`

The only thing which will change is the _condition_ and _UpLink_ values.

So, I was trying to `switch` the message.  
on: `msg.payload.UpLink`  
It wasn't working.  
So I tried `msg.Uplink`. Same.

So at a stretch I tried `msg.condition`. Also failed.

I opened a `debug` window and changed the `msg.payload` to `msg.condition`.

Got this:  
 ![Screenshot%20from%202019-09-12%2015-15-57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a91abdeb468cd7d109d6392fadba4f397255ff22.png)

(Nice I can't copy that. Clicking on the clipboard icon and it says "value coppied" when I paste I got my previous stuff re-pasted.)

Anyway. . . . .

So what's going on?

Putting aside the problems with the switch node - **I found/fixed the problem.**  
Why can't I put `msg.condition` in the debug node and see the value?

While here, about the message _structure_.

`"Who":"TimePi","device":"UpLink"`

(I hope)  
When I am making message (from my post on subflows) I was shown how to make messages.

It was like this:

```auto
msg = {
    payload: "blah",
    other_stuff:"and so on"
}

(Text formatting gone wonky)
Else where I remember the names having ' around them.
Somewhere else it was not the single ' but the `""` ones.
(Second one needed to stop the quote thing happening.)

And the paste above has the names in `""` 

Which is right?
What conditions need which - if any?
```

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [12 September 2019 05:39 UTC](https://discourse.nodered.org/t/help-with-deconstrucing-a-message/15450/2 "2019-09-12T05:39:37Z")

</div>

Whats wrong with this flow? Try it

```auto
[{"id":"32ac6a9a.e0dc56","type":"inject","z":"60f50465.20a53c","name":"","topic":"","payload":"{\"topic\":null,\"host\":null,\"_msgid\":\"a2c057de.049818\",\"_topic\":null,\"payload\":{\"Who\":\"TimePi\",\"device\":\"UpLink\",\"UpLink\":\"Online\"},\"_event\":\"node:97bcd5bc.1a76e8\",\"condition\":\"Online\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":740,"y":100,"wires":[["6b73d521.3f20bc","d72c99a2.1b30f8"]]},{"id":"6b73d521.3f20bc","type":"change","z":"60f50465.20a53c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.payload.UpLink","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":100,"wires":[["9e3078c9.bf4d58"]]},{"id":"d72c99a2.1b30f8","type":"change","z":"60f50465.20a53c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.condition","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":160,"wires":[["9e3078c9.bf4d58"]]},{"id":"9e3078c9.bf4d58","type":"debug","z":"60f50465.20a53c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1210,"y":100,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 September 2019 05:44 UTC](https://discourse.nodered.org/t/help-with-deconstrucing-a-message/15450/3 "2019-09-12T05:44:23Z")

</div>

I have the `debug` node set with `msg.condition` as the thing to display.

The message arrives and I see the error I showed in the picture.

**That** is what's wrong.

It doesn't show me `Online`.

Why?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [12 September 2019 06:25 UTC](https://discourse.nodered.org/t/help-with-deconstrucing-a-message/15450/4 "2019-09-12T06:25:38Z")

</div>

_edit_  
incorrect.

Works here.

If there is no `msg.condition` in the message it will tell you by `undefined`, are you sending more/different payloads?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [12 September 2019 07:08 UTC](https://discourse.nodered.org/t/help-with-deconstrucing-a-message/15450/5 "2019-09-12T07:08:24Z")

</div>

Not that I know.

Thanks.

I'll chalk it up to the unknown.
