Skip to content

转换数据(Transforming data)#

n8n 使用预定义的 数据结构,使所有节点能够正确处理传入的数据。

🌐 n8n uses a predefined data structure that allows all nodes to process incoming data correctly.

你的传入数据可能具有不同的数据结构,在这种情况下,你需要对其进行转换,以便可以单独处理每个项目。

🌐 Your incoming data may have a different data structure, in which case you will need to transform it to allow each item to be processed individually.

例如,下图显示了一个 HTTP 请求 节点的输出,该节点返回的数据与 n8n 的数据结构不兼容。该节点返回数据并显示仅返回了一个项目。

🌐 For example, the image below shows the output of an HTTP Request node that returns data incompatible with n8n's data structure. The node returns the data and displays that only one item was returned.

HTTP Request node output

要将此类结构转换为 n8n 数据结构,你可以使用数据转换节点:

🌐 To transform this kind of structure into the n8n data structure you can use the data transformation nodes:

  • Aggregate:将单独的项目或它们的一部分汇集在一起,组合成单个项目。
  • 限制:移除超过定义最大值的项目。
  • 删除重复项:识别并删除在所有字段或部分字段中相同的条目。
  • 排序:将列表按所需顺序整理,或生成随机选择。
  • 拆分:将包含列表的单个数据项分成多个项。
  • 汇总:将项目聚合在一起,方式类似于 Excel 数据透视表。