How n8n structures data#
Understanding how n8n structures and passes data between nodes is fundamental to building workflows. This guide covers both the data structure format and how data flows through your workflow.
Data structure#
在 n8n 中,节点之间传递的所有数据都是对象数组。它具有以下结构:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
跳过 json 键和数组语法
从 0.166.0 开始,当使用函数节点或代码节点时,如果缺少 json 键,n8n 会自动添加它。如果需要,它还会自动将您的项目包装在数组([])中。这仅在使用函数或代码节点时适用。当构建您自己的节点时,您仍然必须确保节点返回带有 json 键的数据。
How data flows within nodes#
When you connect nodes in a workflow, data automatically passes from one node to the next.
Nodes process multiple items automatically. When a node receives an array of data items, it processes each item individually and performs the configured operation for each one.
For example, if you set the Trello node to Create-Card, and create an expression that sets Name using a property called name-input-value from the incoming data, the node creates a card for each item, always choosing the name-input-value of the current item.
For example, this input will create two cards. One named test1 the other one named test2:
1 2 3 4 5 6 7 8 | |
Understand what you're mapping with drag and drop#
Data mapping maps the field path, and loads the field's value. For example, given the following data:
1 2 3 4 5 6 | |
You can map fruit by dragging and dropping fruit from the INPUT into the field where you want to use its value. This creates an expression, {{ $json.fruit }}. When the node iterates over input items, the value of the field becomes the value of fruit for each item.
Understand nested data#
Given the following data:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
n8n displays it in table form like this:
