跳到主要内容

编辑字段(设置)#

使用编辑字段节点来设置工作流数据。该节点既能设置新数据,也能覆盖已存在的数据。在需要接收前置节点数据的场景中(例如向Google表格或数据库插入值时),此节点至关重要。

节点参数#

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

模式#

可选择使用手动映射通过图形界面编辑字段,或选择JSON输出编写由n8n添加到输入数据中的JSON。

待设置字段#

选择模式 > 手动映射时,可通过从输入区域拖拽数值来配置字段。

拖拽数值时的默认行为是:

  • n8n将数值名称设为字段名
  • 字段值包含访问该数值的表达式

若需禁用表达式:

  1. 将鼠标悬停在字段上,n8n将显示固定值|表达式切换开关
  2. 选择固定值 此操作可同时应用于字段名称和字段值

展示拖拽操作及切换固定值的动态图

仅保留设置字段#

启用后将丢弃未在待设置字段中使用的所有输入数据。

输出包含内容#

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

节点选项#

通过以下选项自定义节点行为。

包含二进制数据#

若输入数据包含二进制数据,可选择是否将其包含在编辑字段节点的输出数据中。

忽略类型转换错误#

仅限手动映射模式。 启用后允许n8n在映射字段时忽略某些数据类型错误。

支持点标记法#

n8n默认支持点标记法。 例如使用手动映射时,节点会遵循名称字段的点标记法。若将名称字段设为number.one字段设为20,最终生成的JSON为:

{ "number": { "one": 20} }

您可以通过选择 添加选项 > 支持点符号,并将 点符号 字段设置为关闭来阻止此行为。现在生成的 JSON 为:

{ "number.one": 20 }

模板与示例#

创建API端点
作者:Jonathan
查看模板详情

使用AI抓取并总结网页内容
作者:n8n团队
查看模板详情

极速快速入门
作者:Deborah
查看模板详情

浏览编辑字段(设置)集成模板,或搜索所有模板

JSON输出模式中的数组与表达式#

创建JSON输出时,您可以使用数组和表达式。

例如,根据客户数据存储节点生成的输入数据:

[
{
"id": "23423532",
"name": "Jay Gatsby",
"email": "gatsby@west-egg.com",
"notes": "Keeps asking about a green light??",
"country": "US",
"created": "1925-04-10"
},
{
"id": "23423533",
"name": "José Arcadio Buendía",
"email": "jab@macondo.co",
"notes": "Lots of people named after him. Very confusing",
"country": "CO",
"created": "1967-05-05"
},
{
"id": "23423534",
"name": "Max Sendak",
"email": "info@in-and-out-of-weeks.org",
"notes": "Keeps rolling his terrible eyes",
"country": "US",
"created": "1963-04-09"
},
{
"id": "23423535",
"name": "Zaphod Beeblebrox",
"email": "captain@heartofgold.com",
"notes": "Felt like I was talking to more than one person",
"country": null,
"created": "1979-10-12"
},
{
"id": "23423536",
"name": "Edmund Pevensie",
"email": "edmund@narnia.gov",
"notes": "Passionate sailor",
"country": "UK",
"created": "1950-10-16"
}
]

JSON 输出 字段中添加以下 JSON,并将 包含在输出中 设置为 所有输入字段

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

您将获得以下输出:

[
{
"id": "23423532",
"name": "Jay Gatsby",
"email": "gatsby@west-egg.com",
"notes": "Keeps asking about a green light??",
"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": "Lots of people named after him. Very confusing",
"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": "Keeps rolling his terrible eyes",
"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": "Felt like I was talking to more than one person",
"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": "Passionate sailor",
"country": "UK",
"created": "1950-10-16",
"newKey": "new value",
"array": [
23423536,
"Edmund Pevensie"
],
"object": {
"innerKey1": "new value",
"innerKey2": "23423536",
"innerKey3": "Edmund Pevensie"
}
}
]