[Solved] Empty templated array is invalid JSON


In my workflow, when a templated value in the “Custom Page Data JSON Template” is an empty array, I get an InvalidJsonError. This can be tested by making a function node with the following code:

payload.deviceList = [];

and then set up the Endpoint Reply as:

If an empty array is used in the JSON Template instead of {{deviceList}}, it works as expected with no error, which leads me to believe the error is unintended.


In your JSON Template, change {{deviceList}} to {{jsonEncode deviceList}} and that should do the trick.

Without the jsonEncode format helper in front of it, your reference is being evaluated as a string (probably spitting out “[object Object]”) hence the failure.

We’ll look into whether there’s a more intuitive way to reference this value, as at first glance we were a little baffled as well. Let us know if you have any more questions.


Yep that works, thanks.