Skip to content

数据结构

在 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
[
	{
		// For most data:
		// Wrap each item in another object, with the key 'json'
		"json": {
			// Example data
			"apple": "beets",
			"carrot": {
				"dill": 1
			}
		},
		// For binary data:
		// Wrap each item in another object, with the key 'binary'
		"binary": {
			// Example data
			"apple-picture": {
				"data": "....", // Base64 encoded binary data (required)
				"mimeType": "image/png", // Best practice to set if possible (optional)
				"fileExtension": "png", // Best practice to set if possible (optional)
				"fileName": "example.png", // Best practice to set if possible (optional)
			}
		}
	},
]

跳过键和数组语法

从 0.166.0 开始,使用 Function 节点或 Code 节点时,如果缺少键,n8n 会自动添加。如果需要,它还会自动将您的项目包装到数组 ( ) 中。这仅在使用 Function 节点或 Code 节点时才会发生。构建您自己的节点时,您仍然必须确保节点返回的数据包含键。

数据项处理

节点可以处理多个项目。

例如,如果将 Trello 节点设置为,并创建一个使用从传入数据调用的属性进行设置的表达式,则该节点会为每个项目创建一张卡片,始终选择当前项目的 。

例如,此输入将创建两张卡片。一张名为 ,另一张名为:

1
2
3
4
5
6
7
8
[
	{
		name-input-value: "test1"
	},
	{
		name-input-value: "test2"
	}
]