跳至内容

数据结构#

在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)
			}
		}
	},
]

跳过json键和数组语法

从0.166.0版本开始,当使用Function节点或Code节点时,如果缺少json键,n8n会自动添加。如果需要,它还会自动将您的项目包装在数组([])中。这仅适用于使用Function或Code节点的情况。在构建自己的节点时,您仍然必须确保节点返回带有json键的数据。

数据项处理#

节点可以处理多个项目。

例如,如果您将Trello节点设置为Create-Card,并创建一个表达式,使用传入数据中名为name-input-value的属性来设置Name,则该节点会为每个项目创建卡片,始终选择当前项目的name-input-value

例如,这个输入将创建两张卡片。一张名为test1,另一张名为test2

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