Hi,
The prepareJSONataExpression does a couple extra things:
- it defines the $flowContext and $globalContext functions that allow an expression to lookup values from context
- it provides a custom clone function - needed as JSONata's native clone function cannot clone some node.js types (as its meant for pure JSON). This is needed in particular when used in a flow that starts with HTTP In as the msg.req and msg.res objects are not cloneable.
- it also assumes you are going to be evaluating
RED.util.prepareJSONataExpression is pretty much a drop-in replacement for the jsonata function. It does take a second argument, the node evaluating the expression if you want to use the flowContext/globalContext functions.
expression = RED.util.prepareJSONataExpression(`{"topic": $jaTopic, "retain": true, "delay": 0,