Strangly Need to add {{ JSON.stringify ($json.output) }}

Describe the problem/error/question

Strangly sometimes i need to add {{ JSON.stringify ($json.output) }} because it wont show me the correct structure on Agent .
Then i redo only {{ $json.output }} and it come back working well .

The problem is that it crash my workflow sometimes and it take me some times to undestand that this things suddenly appear .

No work more:

Rework :

And then Rework ! :

Information on your n8n setup

  • n8nVersion: 1.77.3
  • Running n8n via docker (self-hosted)
  • nodeJsVersion: 20.18.2
  • database: postgres
  • n8n EXECUTIONS_PROCESS setting regular
  • license: enterprise (production)
    • Operating system: Debian 12

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

It’s not strange once you know what’s going on. Internally, in some places, n8n needs the final result of the value/input, for a node parameter, to be a valid JSON string. Sometimes a JS object (different from JSON) still looks exactly like valid JSON (double quotes, array brackets, etc.), so it might work, but you can do some things in JS object syntax that are not allowed in JSON (object notation), so just auto-converting an object to a string does not work.

This post has more detail on how you can more reliably avoid this type of issue in n8n. tl/dr => Use an expression like: {{ { anyValid: 'js object' }.toJsonString() }}

1 Like

Thanks for explanation

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