Hello all,
Would anyone be able to confirm how I would add % after my payload message. It works without the % but when added Node-RED reports the following error:
"Expected "}", got "%""
Working:
{
"message": "The soil moisture level is "& $.payload ,
"title": "Your Rubber Plant Needs Water!"
}
Not Working:
{
"message": "The soil moisture level is "& $.payload "%" ,
"title": "Your Rubber Plant Needs Water!"
}
If you’re doing it with jsonata, you’ll want to change it to:
"message": "The soil moisture level is "& $.payload & "%"
However, I would just change it over to a mustache template:
"message": "The soil moisture level is {{ payload }}%",
Thank you that worked perfectly, out of curiosity why would you use the mustache option over the first solution?
Mustache templates are very lightweight in terms of processing and I find them easier to deal with than jsonata unless I’m doing something more complex than a simple string replacement.
Plus, I use mustache templating a lot in my call-service nodes and they don’t accept jsonata expressions:

1 Like