N8N中文教程
集成节点/Built in_nodes/Core_nodes

编辑字段(设置)#

使用“编辑字段”节点来设置工作流数据。该节点既可以设置新数据,也可以覆盖已存在的数据。在需要从前置节点接收输入数据的工作流中,此节点至关重要,例如向 Google Sheets 或数据库插入值时。

节点参数#

以下是“编辑字段”节点中可用的设置和选项。

模式#

你可以选择使用 手动映射(Manual Mapping) 通过图形界面(GUI)编辑字段,或选择 JSON 输出(JSON Output) 编写 JSON,n8n 会将其添加到输入数据中。

要设置的字段#

如果选择了 模式(Mode) > 手动映射(Manual Mapping),你可以通过从 INPUT(输入) 区域拖放值来配置字段。

默认情况下,当你拖动一个值时:

  • n8n 会将该值的名称设为字段名。
  • 字段值包含一个访问该值的表达式(expression)。

如果你不想使用表达式:

  1. 将鼠标悬停在某个字段上,n8n 会显示 固定值 | 表达式(Fixed | Expressions) 切换按钮。
  2. 选择 固定值(Fixed)

你可以对字段的名称和值都执行此操作。 一个展示拖放操作以及将字段更改为固定值的动图

仅保留设置的字段#

启用此选项后,将丢弃你在 要设置的字段(Fields to Set) 中未使用的任何输入数据。

包含在输出中#

选择哪些输入数据应包含在节点的输出数据中。

节点选项#

使用这些选项来自定义节点的行为。

包含二进制数据#

如果输入数据包含二进制数据(binary data),请选择是否将其包含在“编辑字段”节点的输出数据中。

忽略类型转换错误#

仅适用于手动映射(Manual Mapping)。

启用后,n8n 在映射字段时会忽略某些数据类型错误。

支持点表示法(Dot Notation)#

默认情况下,n8n 支持点表示法(dot notation)。

例如,在使用手动映射时,节点会遵循 名称(Name) 字段中的点表示法。这意味着,如果你在 名称 字段中设置为 number.one,并在 值(Value) 字段中设置为 20,生成的 JSON 将是:

1

| ``` {"number":{"one":20}}


---|---

你可以通过选择 **添加选项(Add Option)** > **支持点表示法(Support Dot Notation)**,并将 **点表示法(Dot Notation)** 字段关闭来禁用此行为。此时生成的 JSON 将变为:

1

| ```
{"number.one":20}

---|---
## 模板与示例#
**创建一个 API 端点**
由 Jonathan 提供
查看模板详情
**使用 AI 抓取并总结网页内容**
由 n8n 团队提供
查看模板详情
**极简快速入门**
由 Deborah 提供
查看模板详情
浏览 Edit Fields (Set) 集成模板,或 搜索所有模板
## JSON 输出模式中的数组与表达式#
在创建 JSON 输出时,你可以使用数组和表达式。

例如,假设有以下由 Customer Datastore 节点生成的输入数据:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

| ```
[
{
"id":"23423532",
"name":"Jay Gatsby",
"email":"gatsby@west-egg.com",
"notes":"一直在问关于绿灯的事??",
"country":"US",
"created":"1925-04-10"
},
{
"id":"23423533",
"name":"José Arcadio Buendía",
"email":"jab@macondo.co",
"notes":"很多人以他命名。非常混乱",
"country":"CO",
"created":"1967-05-05"
},
{
"id":"23423534",
"name":"Max Sendak",
"email":"info@in-and-out-of-weeks.org",
"notes":"总是翻白眼",
"country":"US",
"created":"1963-04-09"
},
{
"id":"23423535",
"name":"Zaphod Beeblebrox",
"email":"captain@heartofgold.com",
"notes":"感觉我好像在跟不止一个人说话",
"country":null,
"created":"1979-10-12"
},
{
"id":"23423536",
"name":"Edmund Pevensie",
"email":"edmund@narnia.gov",
"notes":"狂热的航海爱好者",
"country":"UK",
"created":"1950-10-16"
}
]

---|--- 在 JSON Output 字段中添加以下 JSON 内容,并将 Include in Output 设置为 All Input Fields(包含所有输入字段):

1
2
3
4
5
6
7
8
9

| ``` { "newKey":"new value", "array":[{{$json.id}},"{{ $json.name }}"], "object":{ "innerKey1":"new value", "innerKey2":"{{ $json.id }}", "innerKey3":"{{ $json.name }}", } }

---|--- 你会得到如下输出:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

| ``` [ { "id":"23423532", "name":"Jay Gatsby", "email":"gatsby@west-egg.com", "notes":"一直在问关于绿灯的事??", "country":"US", "created":"1925-04-10", "newKey":"new value", "array":[ 23423532, "Jay Gatsby" ], "object":{ "innerKey1":"new value", "innerKey2":"23423532", "innerKey3":"Jay Gatsby" } }, { "id":"23423533", "name":"José Arcadio Buendía", "email":"jab@macondo.co", "notes":"很多人以他命名,非常混乱", "country":"CO", "created":"1967-05-05", "newKey":"new value", "array":[ 23423533, "José Arcadio Buendía" ], "object":{ "innerKey1":"new value", "innerKey2":"23423533", "innerKey3":"José Arcadio Buendía" } }, { "id":"23423534", "name":"Max Sendak", "email":"info@in-and-out-of-weeks.org", "notes":"总是翻着那双可怕的眼睛", "country":"US", "created":"1963-04-09", "newKey":"new value", "array":[ 23423534, "Max Sendak" ], "object":{ "innerKey1":"new value", "innerKey2":"23423534", "innerKey3":"Max Sendak" } }, { "id":"23423535", "name":"Zaphod Beeblebrox", "email":"captain@heartofgold.com", "notes":"感觉我好像在跟不止一个人说话", "country":null, "created":"1979-10-12", "newKey":"new value", "array":[ 23423535, "Zaphod Beeblebrox" ], "object":{ "innerKey1":"new value", "innerKey2":"23423535", "innerKey3":"Zaphod Beeblebrox" } }, { "id":"23423536", "name":"Edmund Pevensie", "email":"edmund@narnia.gov", "notes":"狂热的航海爱好者", "country":"UK", "created":"1950-10-16", "newKey":"new value", "array":[ 23423536, "Edmund Pevensie" ], "object":{ "innerKey1":"new value", "innerKey2":"23423536", "innerKey3":"Edmund Pevensie" } } ]


---|---