← Back to Home

JSONata, when used in Change and Switch nodes, offers several advantages over the Function node:
Simplicity and Readability: JSONata expressions are concise and easy to read. They allow you to perform complex operations without writing custom JavaScript code. If your logic involves simple transformations or filtering, JSONata can simplify your flow.

No JavaScript Knowledge Required:
JSONata doesn’t require knowledge of JavaScript. You can achieve powerful data manipulation without writing any code. This is especially helpful for users who are not comfortable with programming.

Built-In Functions:
JSONata provides built-in functions for common tasks (e.g., filtering, mapping, averaging). You can leverage these functions directly within your flow. No need to reinvent the wheel by writing custom functions.

Performance and Efficiency:
JSONata expressions are optimized for performance. They execute faster than custom JavaScript code in many cases. If your flow processes large amounts of data, JSONata can be more efficient.

Visual Flow Design:
Using JSONata in Change and Switch nodes keeps your flow visually clean. You can see the data transformations directly in the flow editor. This improves maintainability and collaboration.

Avoiding Errors:
JSONata expressions are less error-prone than writing custom JavaScript. They handle edge cases and type conversions automatically. This reduces the risk of bugs and unexpected behavior.

However, there are scenarios where the Function node is more suitable, such as complex custom logic or interactions with external APIs. Consider using JSONata when it aligns with your specific use case and simplifies your flow. 😊

You can run this flow using a WebContainer. Click here.
This will start node-red in your browser.