Skip to content

在 UI 中进行映射#

¥Mapping in the UI

数据映射是指引用来自先前节点的数据。它不包含更改(转换)数据的操作,仅包含引用操作。

¥Data mapping means referencing data from previous nodes. It doesn't include changing (transforming) data, just referencing it.

你可以通过以下方式映射数据:

¥You can map data in the following ways:

  • 使用表达式编辑器。

¥Using the expressions editor.

  • 通过将数据从输入节点拖放到参数中。这将为你生成表达式。

¥By dragging and dropping data from the INPUT into parameters. This generates the expression for you.

有关映射和链接项时出现的错误信息,请参阅 项目链接错误

¥For information on errors with mapping and linking items, refer to Item linking errors.

如何拖放数据#

¥How to drag and drop data

  1. 运行你的工作流以加载数据。

¥Run your workflow to load data. 2. 打开需要映射数据的节点。

¥Open the node where you need to map data. 3. 你可以在表格、JSON 和模式视图中进行映射:

¥You can map in table, JSON, and schema view:

  • 表格视图:单击并按住表格标题以映射顶层数据,或单击并按住表格中的字段以映射嵌套数据。

    ¥In table view: click and hold a table heading to map top level data, or a field in the table to map nested data.

  • 在 JSON 视图中:单击并按住某个键。

    ¥In JSON view: click and hold a key.

  • 架构视图:单击并按住某个键。

    ¥In schema view: click and hold a key. 4. 将项目拖到要使用数据的字段中。

¥Drag the item into the field where you want to use the data.

理解拖放映射的内容删除#

¥Understand what you're mapping with drag and drop

数据映射映射键路径,并将键的值加载到字段中。例如,给定以下数据:

¥Data mapping maps the key path, and loads the key's value into the field. For example, given the following data:

1
2
3
4
5
6
[
	{
		"fruit": "apples",
		"color": "green"
	}
]

你可以将水果从输入框拖放到你想要使用其值的字段中,从而映射 fruit。此教程将创建一个表达式 {{ $json.fruit }}。当节点遍历输入项时,每个项的字段值都会变为 fruit 的值。

¥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
[
  {
    "name": "First item",
    "nested": {
      "example-number-field": 1,
      "example-string-field": "apples"
    }
  },
  {
    "name": "Second item",
    "nested": {
      "example-number-field": 2,
      "example-string-field": "oranges"
    }
  }
]

n8n 以表格形式显示如下内容:

¥n8n displays it in table form like this:

"Screenshot of a table in the INPUT panel. It includes a top level field named "nested." This field contains nested data, which is indicated in bold."