JSON on exec nodes

Hello, everyone I am parsing python output that is in JSON format, it is received by the exec node as string so I added a JSON node on the output. It's working fine on slow data rate, when it goes above 500Hz, The exec node receives two outputs in same msg and the JSON node will fail to translate it. Here is a picture of the structure and the output error.

image

and the flow code:

[{"id":"b8aed3a2.c3dc18","type":"tab","label":"Example"},{"id":"dd1c240f.565df8","type":"exec","z":"b8aed3a2.c3dc18","command":"python3 /home/pi/SMARTVILLE_SlAVE/src/CAN_REC.py","addpay":"","append":"","useSpawn":"true","timer":"","oldrc":false,"name":"python run","x":610,"y":440,"wires":[["beea5760.b88c78","a90958a.7c3ada8"],[],[]]},{"id":"4350a958.a4c2e8","type":"inject","z":"b8aed3a2.c3dc18","name":"Start System","props":[],"repeat":"","crontab":"","once":true,"onceDelay":"3","topic":"","x":430,"y":440,"wires":[["dd1c240f.565df8"]]},{"id":"a90958a.7c3ada8","type":"json","z":"b8aed3a2.c3dc18","name":"","property":"payload","action":"obj","pretty":false,"x":890,"y":340,"wires":[["75dc7e2e.ca28f"]]},{"id":"beea5760.b88c78","type":"debug","z":"b8aed3a2.c3dc18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":280,"wires":[]},{"id":"75dc7e2e.ca28f","type":"debug","z":"b8aed3a2.c3dc18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":340,"wires":[]}]

Looks like there is a line break on there between the two results. Can you split the string on that into two messages then pass to the json node?

This in a function before the json node should split the payload, whether there is a space or carriage return or not.

msg.payload=msg.payload.split(/(?<=})\s*(?=\{)/g);
msg.payload.forEach(e => node.send({payload:e}))
return null;

That is perfectly working, Thank you!