Default naming next connect node as 'json' causes issues

When connecting to the output of a node, the default is to reference the output as $json. The problem with this is if you then add another node in-between the relationship breaks

Hi @samp

$json is always for the direct input of the node. You can also reference data from nodes previous to that.
Have you had a look at the 2 courses n8n offer, they will explain the workings of nodes and items.

Hi @BramKn,

Thank you for your response. I will have a read through these courses!

What I was thinking would be helpful if if n8n could auto update the nodes reference when you add an additional node. This way it would not break the flow.

Hi @samp

Not sure if I understand correctly.
Do you mean that you have a node with expressions using $json, then you add a node in between outputting other data and you still want to use the original data from the node which is now 2 nodes back?
If so, yes this would be helpful sometimes, but most of the time it will cause issues and data conflicts. For example when there is more items because you are getting data from an API.
So sometimes it would need to do it, and sometimes it should not. Personally I would not like n8n making those choices for me.

Luckily we can easily use a Merge node to add the data from the 2 nodes together before feeding it into the node making $json work still. :slight_smile: