How to get json into a inject

I'm sure this should be easy but I just can't seem to get my head around this:-

[topic
switch can be used to change device state. The message will be something like this: { topic: "switch", payload: { value: (1|0) } }
"]
and this:-
[{
topic: "switch",
payload: {
value: 1
}
}]
is what I am looking at but I just cant seem to get the inject node set up
everything I have tried when I debug from the node, the Value no longer appears to be there

this is what I start with
deviceId: "db1241be-ca6c-46d1-9606-9067fbc128ba"
deviceType: "switch"
name: "lounge colour2"
value: 0

this is what I end up with
deviceId: "db1241be-ca6c-46d1-9606-9067fbc128ba"
deviceType: "switch"
name: "lounge colour2"

(the value: no longer there)

I really hope this make sense to someone

Can you post what you've currently got in the inject node. I assume it will be something like:

{ value: 1 }

And the payload type will be set to JSON. I'm finding your question a bit difficult to follow.

that is what I thought but it does not seem to like it
image
keeps telling me bad string

what am i doing wrong?

Change it to:

{ "value": 1 }

JSON requires "quotes" around all strings.

Thanks you so much I think I was doing it after the : ("value:") doing it as you have shown has resolved it

I new it was me just could not see it!!!!

Thanks again

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