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:

  • 使用表达式编辑器。
  • 通过将数据从 输入 拖放到参数中。这会为你生成表达式。

有关映射和关联项目错误的信息,请参阅 项目关联错误

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

如何拖放数据(How to drag and drop data)#

  1. 运行你的工作流以加载数据。
  2. 打开需要映射数据的节点。
  3. 你可以在表格、JSON 和模式视图中进行映射:
    • 在表格视图中:点击并按住表头以映射顶层数据,或点击表格中的字段以映射嵌套数据。
    • 在 JSON 视图中:点击并按住一个键。
    • 在模式视图中:点击并按住一个键。
  4. 将项目拖到要使用数据的字段中。

理解拖放映射的内容删除(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"
	}
]

你可以通过将 INPUT 中的 水果 拖放到你想使用其值的字段中来映射 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."