跳到主要内容

数据结构#

在n8n中,所有在节点间传递的数据均为对象数组。其结构如下:

[
{
// 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

[
{
name-input-value: "test1"
},
{
name-input-value: "test2"
}
]