$json considered harmful?

When you create a new node3, using data from the previous node1, it’s referenced as $json.foo, but as soon as you add a new node2 between node1 and node3, the node3’s $json.foo becomes invalid (the new node2 is not yielding a foo property).

I think all data references should be absolute references ( $input['node1'].item.json.foo ).
Or maybe this could be a configuration option? “When dragging and dropping a key from the schema, create [absolute | relative] references”

Hey @Martin_Sarsale1 hope all is well, welcome to the community.

I think when you are building the flow, you rarely don’t know where you are taking the data from - last node or one of the nodes before that. Being able to reference the last node’s value with just $json.value is a good convenience, makes expressions easier to read and most importantly doesn’t rely on the node’s name which can be changed at any time.

Think about it, you create a node with the default name, use it in 25 other nodes by name and being a perfectionist you will want to prettify the flow when done - you rename the node to something actually useful and there you have it - now you need to go and change it in 25 other places.

In my opinion, having it both ways is beneficial and makes total sense.

When you rename a node, all the explicit references to that node are automatically updated.

Ha, thank you I didn’t know that.

The rest stands true though - the convenience of not having to type the name of the node, shorter and easier to read look, and honestly this syntax is all most small flows need anyway.

It also makes it easier to re-use parts of the workflow (in your own workflows or when shared) - relying on previous node’s data is a common practice and used in most neighbouring node communications.