# JSON on exec nodes

**URL:** <https://discourse.nodered.org/t/json-on-exec-nodes/49551>\
**Category:** General\
**Created:** [10 August 2021 02:34 UTC](https://discourse.nodered.org/t/json-on-exec-nodes/49551 "2021-08-10T02:34:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mafify](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mafify](https://discourse.nodered.org/u/mafify)\
**Post date:** [10 August 2021 02:34 UTC](https://discourse.nodered.org/t/json-on-exec-nodes/49551/1 "2021-08-10T02:34:01Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a8dce1c8e073c4ede45ae5b1550b986d94bed373.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/1/613583e32108d8a9fdaa21b8804122c7bbade66b.png)

and the flow code:

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 August 2021 06:48 UTC](https://discourse.nodered.org/t/json-on-exec-nodes/49551/2 "2021-08-10T06:48:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [10 August 2021 14:00 UTC](https://discourse.nodered.org/t/json-on-exec-nodes/49551/3 "2021-08-10T14:00:52Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![mafify](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mafify](https://discourse.nodered.org/u/mafify)\
**Post date:** [11 August 2021 21:26 UTC](https://discourse.nodered.org/t/json-on-exec-nodes/49551/4 "2021-08-11T21:26:02Z")

</div>

That is perfectly working, Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 September 2021 17:46 UTC](https://discourse.nodered.org/t/json-on-exec-nodes/49551/5 "2021-09-15T17:46:11Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
