# Join node throwing Unexpected end of JSON error

**URL:** <https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476>\
**Category:** General\
**Created:** [9 November 2021 21:09 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476 "2021-11-09T21:09:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlongfield](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rlongfield/32/14264_2.png) [@rlongfield](https://discourse.nodered.org/u/rlongfield)\
**Post date:** [9 November 2021 21:09 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/1 "2021-11-09T21:09:14Z")

</div>

I just started working with Rhasspy and using Node-Red to handle the intents from Rhasspy.  
I am getting the ' Unexpected end of JSON input error' on a join node when I try to combine 2 payloads into one.

I'm still learning NR and I'm sure I've mucked something up somewhere. I've tested and everything works up until the Join.

So in a netshell, the intent triggers 2 nodes to grab data from Home Assistant, then I use funtion nodes to give some words to the data, then change nodes to set different msg.topic values, followed by a join to combine them, except the join doesn't.

`[{"id":"5754556a.c9ebbc","type":"api-current-state","z":"c9c0d07b.2751c","name":"House Temperature","server":"890f6b21.aaf278","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"sensor.house_temperature","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":430,"y":380,"wires":[["16a3a357.5bb1cd"]]},{"id":"af88e8c3.01eda8","type":"api-current-state","z":"c9c0d07b.2751c","name":"Outside Temperature","server":"890f6b21.aaf278","version":1,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is_not","override_topic":false,"entity_id":"sensor.temperature","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":260,"y":480,"wires":[["8cc48f57.6aaf7"]]},{"id":"8cc48f57.6aaf7","type":"function","z":"c9c0d07b.2751c","name":"Outside Temp prefix","func":"msg.payload = \"It is\" + msg.payload + \"degrees outside\";\nreturn msg;","outputs":1,"noerr":0,"x":480,"y":480,"wires":[["c2e216ec.273778","6e846956.116f08"]]},{"id":"16a3a357.5bb1cd","type":"function","z":"c9c0d07b.2751c","name":"House Temp prefix","func":"msg.payload = \"and\" + msg.payload + \"degrees inside\";\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":380,"wires":[["4539666.d209598","6e846956.116f08"]]},{"id":"c2e216ec.273778","type":"change","z":"c9c0d07b.2751c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":480,"wires":[["a8511133.286cb"]]},{"id":"4539666.d209598","type":"change","z":"c9c0d07b.2751c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":380,"wires":[["a8511133.286cb"]]},{"id":"a8511133.286cb","type":"join","z":"c9c0d07b.2751c","name":"Output Test","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"bin","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":930,"y":440,"wires":[["812b9af3.882998","6e846956.116f08"]]},{"id":"6e846956.116f08","type":"debug","z":"c9c0d07b.2751c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":770,"y":660,"wires":[]},{"id":"890f6b21.aaf278","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]`

Appraciate any assist on this

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2021 21:40 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/3 "2021-11-09T21:40:12Z")

</div>

I have taken out the HA nodes and replaced them with Inject nodes so that it can be tested without the HA nodes and it works ok for me.  
Which version of node-red are you using? Edit: Also tell us the nodejs version, the command `node -v` will tell you that.  
Are you sure it is the Join node that is showing the error? Can you do a screenshot of the error?

For the future please see this post for how to share flows here, it makes it easier to copy them if you do that. [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

Here is my flow, does it fail for you?

```auto
[{"id":"8cc48f57.6aaf7","type":"function","z":"84405ff5.25fa6","name":"Outside Temp prefix","func":"msg.payload = \"It is\" + msg.payload + \"degrees outside\";\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":2140,"wires":[["c2e216ec.273778","6e846956.116f08"]]},{"id":"16a3a357.5bb1cd","type":"function","z":"84405ff5.25fa6","name":"House Temp prefix","func":"msg.payload = \"and\" + msg.payload + \"degrees inside\";\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":2040,"wires":[["4539666.d209598","6e846956.116f08"]]},{"id":"c2e216ec.273778","type":"change","z":"84405ff5.25fa6","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":2140,"wires":[["a8511133.286cb"]]},{"id":"4539666.d209598","type":"change","z":"84405ff5.25fa6","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":2040,"wires":[["a8511133.286cb"]]},{"id":"a8511133.286cb","type":"join","z":"84405ff5.25fa6","name":"Output Test","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"bin","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":850,"y":2100,"wires":[["6e846956.116f08"]]},{"id":"6e846956.116f08","type":"debug","z":"84405ff5.25fa6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":2320,"wires":[]},{"id":"0cc9d49e1b988ba6","type":"inject","z":"84405ff5.25fa6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":2040,"wires":[["16a3a357.5bb1cd"]]},{"id":"ba4f029073cd74ba","type":"inject","z":"84405ff5.25fa6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":2140,"wires":[["8cc48f57.6aaf7"]]}]

```

---

<div class="post-metadata">

**Author:** ![rlongfield](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rlongfield/32/14264_2.png) [@rlongfield](https://discourse.nodered.org/u/rlongfield)\
**Post date:** [10 November 2021 00:28 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/4 "2021-11-10T00:28:58Z")

</div>

@Colin Your flow fails with the same error.

It appears I'm a bit behind on my Node-Red, I'm running 1.0.2  
nodejs is 10.16.3

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 November 2021 08:14 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/5 "2021-11-10T08:14:47Z")

</div>

I can confirm that the flow I posted fails on 1.0.4 so it must be a bug that has been fixed since then. The solution appears to be to upgrade node-red.

**[Edit]** It works on 1.3.3. Both use nodejs 10.x so it probably is the node-red version not nodejs.

---

<div class="post-metadata">

**Author:** ![rlongfield](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rlongfield/32/14264_2.png) [@rlongfield](https://discourse.nodered.org/u/rlongfield)\
**Post date:** [10 November 2021 13:29 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/6 "2021-11-10T13:29:34Z")

</div>

@Colin I upgraded to 2.1.3 and your test flow doesn't fail.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 November 2021 13:58 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/7 "2021-11-10T13:58:09Z")

</div>

Presumably your real flow is ok too.

---

<div class="post-metadata">

**Author:** ![rlongfield](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rlongfield/32/14264_2.png) [@rlongfield](https://discourse.nodered.org/u/rlongfield)\
**Post date:** [10 November 2021 14:37 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/8 "2021-11-10T14:37:00Z")

</div>

@Colin

It's not actually, well sort of.  
It's grabbing the correct data but the entire template code is being passed as the text to speak.

So when I ask for the temperature Rhasspy speaks the following;  
`{"1":"It is6.1degrees outside","2":"and21.0degrees inside"}`

Is this happening because my join is set to create 'a key/value object'?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 November 2021 14:53 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/9 "2021-11-10T14:53:29Z")

</div>

Is this the same question as your [other thread](https://discourse.nodered.org/t/struggle-after-nr-upgrade/53507)?

---

<div class="post-metadata">

**Author:** ![rlongfield](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rlongfield/32/14264_2.png) [@rlongfield](https://discourse.nodered.org/u/rlongfield)\
**Post date:** [10 November 2021 15:05 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/10 "2021-11-10T15:05:01Z")

</div>

@Colin  
Similar issue, thinking the other thread is a better location for this.

---

<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:** [9 January 2022 15:05 UTC](https://discourse.nodered.org/t/join-node-throwing-unexpected-end-of-json-error/53476/11 "2022-01-09T15:05:17Z")

</div>

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