Node-Red – Using MSG fields on JSONata expression
I’m using Node-Red.
I have set a field named “counter” for msg object, I want to use it’s value in an JSONata expression, the expression is this:
$keys(payload)[counter]
Consider this payload:
{
"counter": 0,
"payload": {"cv": 1, "fg": 2}
}
When I test it, I get this result:
When I enter 0 directly instead of using counter, it shows the correct result and when I just use “counter” as expression, it evaluate it as 0
Why the main expression is not evaluating correctly?
How should I write it?
Read more here: Source link



