I was surprised to find that the following does not lead to the “true” path being taken, despite the value of data.is_end
being set to true
:
{{data.is_end}} == true
Whereas the following expression did take the “true” path:
{{data.is_end}}
The value in data.is_end was inserted by a Mutate node with the value true
. The debug output shows data.is_end= "true"
(with the quotes).
My original understanding was that the Mutate node would add a property to the data
object of type boolean
. Is this correct? If so, why is my original comparison failing?
So, @Alexander_Farley,
Our templating engine is HandleBars JS. So we follow all of the JavaScript truthiness evaluation rules.
In this case, "true" == true
will result to false.
But, you make a good point about the Mutate Note. For that to evaluate the types as expected, you’ll need to use the “Treat value as JSON” option. ( in the example below, the bottom arrow is after, and the top before )
The reason for this is, the result of all templates are strings. Now, Losant is friendly in a lot of places. For example, when you report a boolean state, we do convert the type of that value for you.
However, in this case, it will be a string unless you select that option. Your string will be evaluated as JSON, which has types. It’s almost the equivalent of doing: