JSONata falls back to compatibility mode when there's a string ' msg ' (msg with spaces on both sides) in it. Is this intentional? (Node-RED 3.1.3 on NodeJS 18 and 20)
This means that this JSONata expression doesn't give back the payload:
"foo msg -" & payload
while this one works as I'd expect:
"msg -" & payload
Demonstration flow:
[
{
"id": "f08d2f8c04cbd984",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "342e03da63c86385",
"type": "inject",
"z": "f08d2f8c04cbd984",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 80,
"wires": [
[
"781b0f561050b4d2"
]
]
},
{
"id": "781b0f561050b4d2",
"type": "change",
"z": "f08d2f8c04cbd984",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payloadstring",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 370,
"y": 80,
"wires": [
[
"6189491046e60713"
]
]
},
{
"id": "5a7bbf556fb06a5c",
"type": "debug",
"z": "f08d2f8c04cbd984",
"name": "debug msg object",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 650,
"y": 200,
"wires": []
},
{
"id": "6189491046e60713",
"type": "change",
"z": "f08d2f8c04cbd984",
"name": "",
"rules": [
{
"t": "set",
"p": "JSONata-value1",
"pt": "msg",
"to": "\"foo msg - \" & payload",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 140,
"wires": [
[
"ef3ae5a3f618a952"
]
]
},
{
"id": "ef3ae5a3f618a952",
"type": "change",
"z": "f08d2f8c04cbd984",
"name": "",
"rules": [
{
"t": "set",
"p": "JSONata-value2",
"pt": "msg",
"to": "\"msg - \" & payload",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 200,
"wires": [
[
"5a7bbf556fb06a5c"
]
]
},
{
"id": "30dffede0d1ea381",
"type": "comment",
"z": "f08d2f8c04cbd984",
"name": "the first JSONata expression accidentally falls back to compatibility mode ",
"info": "",
"x": 820,
"y": 140,
"wires": []
}
]
I can file an issue on Github if needed.