Node-red Json strings - escape charater

Im trying to create a json string to control my hue light and yeelight. I having problems with creating my json string. My function node were I try to create it looks like this:

var SetTemp = msg.payload;

msg.payload = "{"+ """ct""" + ":[" + SetTemp + "]}";
msg.LightType = "Hue_Color"
return msg;

I get (not surprisingly) an error in the “”"
I need some kind of escape charater.

Can anybody help, please?

Escape the extra " using \

"{" + "\"ct\"" + ":[" + SetTemp + "]}"

No semicolon is required.

2 Likes