
工作原理
本模板是一个互动式分步教程,旨在教会您 n8n 中最关键的技能:使用表达式来访问和操作数据。
如果您了解 JSON 但不确定如何从一个节点提取特定信息并在另一个节点中使用,这个工作流正适合您。它从充当文件柜的单一"源数据"节点开始,然后引导您完成一系列课程,每节课都演示一种检索和转换数据的新技术。
您将学习如何:
- 从前置节点获取简单数值
- 使用 n8n 内置选择器如
.last()
和.first()
- 从list (Array)中获取特定项
- 深入嵌套data (Objects)内部
- 结合这些技巧来访问 array of objects中的数据。
- 通过使用 JavaScript 函数进行数学运算或修改文本,实现超越简单检索的操作。
- 使用
Object.keys()
和JSON.stringify()
等实用函数检查数据。 - 利用
.all()
和箭头函数对multiple items进行汇总。
什么是表达式?
表达式是一小段代码,放在双大括号 {{ }}
内,当工作流运行时会被动态值替换。它是连接各个节点的"胶水"。
数据来源
此节点包含了本教程的所有示例数据。可以把它想象成一个文件柜,其他所有节点都会从这个柜子里获取特定的信息。
查看它的输出以熟悉数据结构。我们有:
- 简单文本(
name
) - 数字(
age
) - 技能列表(
skills
) - 复杂项目列表(
projects
) - 嵌套的联系人对象(
contact
)

第 1 课:访问简单值
这是你在 n8n 中最常做的操作。
目标: 从 "Source Data" 节点获取用户的姓名。
表达式: {{ $('Source Data').item.json.name }}
解析:
{{ ... }}
:告诉 n8n "这是一个动态表达式"。$('Source Data')
:选择我们想要获取数据的节点。.item.json
:缩小范围到当前项目的 JSON 数据。.name
:选择我们想要获取值的具体 键。
其他可能方式:
- 也可以把右侧字段拖拽到输入框
- 在这种情况下,
{{ $json.name }}
也可以使用,因为$json
可以访问前一个节点的数据。

第 2 课:n8n 选择器(.first()
、.last()
、.all()
)
在上一课中,我们使用了 .item
。当一个节点只输出一个项目时,这等同于 .last()
。显式使用 .last()
往往更安全、更清晰。
目标: 使用 .last()
选择器获取用户姓名。
表达式: {{ $('Source Data').last().json.name }}
为什么这样更好? 如果一个节点返回多个项目,.last()
可以保证你只获取最后一个项目的数据。
如果你需要将选中的数据与输入项目匹配,这时 .item
是无法替代的。
其他选择器:
.first()
:获取第一个项目的数据。.all()
:获取所有项目的数据,返回为对象数组。(这与$items
不同!)

第 3 课:访问数组元素
如果数据在列表(数组)中呢?你需要指定想要的哪一项。
目标: 获取用户的第二项技能。
表达式: {{ $('Source Data').last().json.skills[1] }}
解析:
...skills
:选择技能数组。[1]
:选择特定位置的元素。- 重要提示: 数组是"从零开始索引"的,这意味着第一项是
[0]
,第二项是[1]
,第三项是[2]
,以此类推。

第 4 课:访问嵌套数据
有时,数据会被组织在对象内部的对象中。
目标: 获取用户的电子邮件地址。
表达式: {{ $('Source Data').last().json.contact.email }}
解析:
...contact
:首先访问contact
对象。.email
:然后再使用一个点.
进入下一层,获取其中email
键的值。

第 5 课:访问对象数组中的数据
这是对前几课内容的终极考验!
目标: 获取列表中第一个 项目的 status。
表达式: {{ $('Source Data').last().json.projects[0].status }}
解析:
...projects
:选择项目数组。[0]
:选择数组中的第一个对象。.status
:从该对象中获取status
键的值。

第 6 课:一点魔法(JS 函数)
你不仅可以获取数据,还可以操作和检查数据!
表达式示例:
- 转换文本:
{{ $('Source Data').last().json.name.toUpperCase() }}
- 数学运算:
{{ Math.round($('Source Data').last().json.age / 7) }}
- 检查数据类型:
{{ typeof $('Source Data').last().json.age }}
解析:
.toUpperCase()
:字符串的标准 JavaScript 函数,用于转换为大写。Math.round(...)
:Math
对象提供强大的数学函数。typeof
:一个操作符,用于告诉你当前数据的类型(如 "string"、"number"、"object" 等)。

第 7 课:检查对象(Object.keys()
)
如果你有一个对象,但不知道里面有哪些键,该怎么办?Object.keys()
就能派上用场。
目标: 获取 contact
对象中所有键的列表。
表达式: {{ Object.keys($('Source Data').last().json.contact) }}
这在动态处理数据时非常有用。它会返回一个数组 ,包含所有键的名称(例如 ["email", "phone"]
)。

第 8 课:实用函数(JSON.stringify()
)
有时你需要将结构化的 JSON 对象转换回一个干净的单行字符串。这在向其他服务发送数据时很常见,比如在 AI 提示中。
目标: 将整个 contact
对象转换为格式化字符串。
表达式: {{ JSON.stringify($('Source Data').last().json.contact, null, 2) }}
解析:
JSON.stringify(...)
:执行转换的函数。null, 2
:可选参数,用于"美化输出",在字符串中添加 2 个空格缩进,使其更易读。

第 9 课:处理多个项目($items
与箭头函数)
如果一个节点输出多个 项目,而你想对它们进行汇总,该用 $items()
。
目标: 获取所有用户技能,并合并成一个逗号分隔的字符串。
表达式: {{ $('Split Out Skills').all().map(item => item.json.skills).join(', ') }}
什么是 item => ...
? 这是箭头函数(Arrow Function),是一种"对每个元素执行某个操作"的简写形式。
item
:在循环中临时代表当前项目的变量名。=>
:箭头,用于分隔元素和要执行的操作。item.json.skills
:要执行的操作------这里是从每个项目中获取技能值。


🎓 期末考试:综合应用
这个节点运用我们学过的所有知识,构建了一个最终的汇总对象。

其他
- 引用:点击阅读原文
- 代码
json
{
"name": "4、 精通 n8n 表达式",
"nodes": [
{
"parameters": {},
"id": "22a8e2c9-c7a3-4851-9be7-a936731b658e",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Start Tutorial",
"type": "n8n-nodes-base.manualTrigger",
"creator": "Lucas Peyrin",
"position": [
-7680,
1296
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "# 教程 - 精通 n8n 表达式\n\n欢迎!你已经了解了 JSON。现在,让我们学习如何**使用它**。此工作流将教你如何使用 n8n 强大的表达式,从一个节点获取数据并在另一个节点中使用。\n\n**什么是表达式?**\n表达式是一小段代码,放在双大括号 `{{ }}` 内,当工作流运行时会被动态值替换。它是连接各个节点的"胶水"。\n\n**如何使用本教程:**\n\n1. 第一个节点 **"Source Data"** 包含了我们将使用的所有数据。执行一次以查看内容。\n2. 按从上到下的顺序依次操作,每个节点都是一个新的课程。\n3. 阅读每节课的便利贴,然后查看节点的配置及其输出以理解概念。\n",
"height": 560,
"width": 640,
"color": 5
},
"id": "089343d8-70e9-45ae-96b1-026705fd4407",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-7936,
896
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "name",
"type": "string",
"value": "Alice"
},
{
"id": "67890",
"name": "age",
"type": "number",
"value": 30
},
{
"id": "abcde",
"name": "is_active",
"type": "boolean",
"value": true
},
{
"id": "fghij",
"name": "skills",
"type": "array",
"value": "[\"JavaScript\",\"Python\",\"n8n\"]"
},
{
"id": "klmno",
"name": "projects",
"type": "array",
"value": "[{\"name\":\"Project A\",\"status\":\"Done\"},{\"name\":\"Project B\",\"status\":\"In Progress\"}]"
},
{
"id": "pqrst",
"name": "contact",
"type": "object",
"value": "{\"email\":\"alice@example.com\",\"phone\":null}"
}
]
},
"options": {}
},
"id": "7309f5f4-d788-47cf-8450-cbf2efba390e",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Source Data",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-7040,
1296
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 我们的数据来源\n\n此节点包含了本教程的所有示例数据。可以把它想象成一个文件柜,其他所有节点都会从这个柜子里获取特定的信息。\n\n查看它的输出以熟悉数据结构。我们有:\n\n* 简单文本(`name`)\n* 数字(`age`)\n* 技能列表(`skills`)\n* 复杂项目列表(`projects`)\n* 嵌套的联系人对象(`contact`)\n",
"height": 520,
"width": 520,
"color": 7
},
"id": "0583b6f6-1827-4cd4-b9bd-b22033d90f4e",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-7264,
944
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "user_name",
"type": "string",
"value": "={{ $('Source Data').item.json.name }}"
}
]
},
"options": {}
},
"id": "74682597-f0d1-46e8-bb61-eb4e1ccefb7c",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "1. The Basics",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-6512,
1296
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 1 课:访问简单值\n\n这是你在 n8n 中最常做的操作。\n\n**目标:** 从 "Source Data" 节点获取用户的姓名。\n\n**表达式:** `{{ $('Source Data').item.json.name }}`\n\n**解析:**\n\n* `{{ ... }}`:告诉 n8n "这是一个动态表达式"。\n* `$('Source Data')`:选择我们想要获取数据的节点。\n* `.item.json`:缩小范围到当前项目的 JSON 数据。\n* `.name`:选择我们想要获取值的具体 **键**。\n\n**其他可能方式:**\n在这种情况下,`{{ $json.name }}` 也可以使用,因为 `$json` 可以访问前一个节点的数据。\n",
"height": 580,
"width": 500,
"color": 2
},
"id": "a7f60172-a141-4298-82ea-58685f51f03b",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-6720,
880
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "second_skill",
"type": "string",
"value": "={{ $('Source Data').last().json.skills[1] }}"
}
]
},
"options": {}
},
"id": "6eda656f-14c7-4898-971b-267f28a850bd",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "3. Working with Arrays",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-5280,
1296
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 3 课:访问数组元素\n\n如果数据在列表(数组)中呢?你需要指定想要的*哪一项*。\n\n**目标:** 获取用户的*第二项*技能。\n\n**表达式:** `{{ $('Source Data').last().json.skills[1] }}`\n\n**解析:**\n\n* `...skills`:选择技能数组。\n* `[1]`:选择特定位置的元素。\n* **重要提示:** 数组是"从零开始索引"的,这意味着第一项是 `[0]`,第二项是 `[1]`,第三项是 `[2]`,以此类推。\n",
"height": 520,
"width": 540,
"color": 4
},
"id": "bd10aa33-cc5f-4791-983a-8020fdd7be9a",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-5488,
928
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "user_email",
"type": "string",
"value": "={{ $('Source Data').last().json.contact.email }}"
}
]
},
"options": {}
},
"id": "56b9b7f6-125a-4228-8331-5e041ae36b3c",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "4. Going Deeper",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-7056,
1888
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 4 课:访问嵌套数据\n\n有时,数据会被组织在对象内部的对象中。\n\n**目标:** 获取用户的电子邮件地址。\n\n**表达式:** `{{ $('Source Data').last().json.contact.email }}`\n\n**解析:**\n\n* `...contact`:首先访问 `contact` 对象。\n* `.email`:然后再使用一个点 `.` 进入下一层,获取其中 `email` 键的值。\n",
"height": 480,
"width": 540,
"color": 5
},
"id": "30351755-9705-4928-b80e-91c6830bb212",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-7264,
1568
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "first_project_status",
"type": "string",
"value": "={{ $('Source Data').last().json.projects[0].status }}"
}
]
},
"options": {}
},
"id": "6e9a1a5e-6048-4b11-ba5c-137f3913fbe8",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "5. The Combo Move",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-6464,
1888
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 5 课:访问对象数组中的数据\n\n这是对前几课内容的终极考验!\n\n**目标:** 获取列表中*第一个*项目的 *status*。\n\n**表达式:** `{{ $('Source Data').last().json.projects[0].status }}`\n\n**解析:**\n\n1. `...projects`:选择项目数组。\n2. `[0]`:选择数组中的第一个对象。\n3. `.status`:从该对象中获取 `status` 键的值。\n",
"height": 480,
"width": 580,
"color": 6
},
"id": "74f13f66-43a1-4f1c-9d57-cab946a2f24a",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-6704,
1568
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "name_in_caps",
"type": "string",
"value": "={{ $('Source Data').last().json.name.toUpperCase() }}"
},
{
"id": "67890",
"name": "age_in_dog_years",
"type": "number",
"value": "={{ Math.round($('Source Data').last().json.age / 7) }}"
},
{
"id": "abcde",
"name": "age_data_type",
"type": "string",
"value": "={{ typeof $('Source Data').last().json.age }}"
}
]
},
"options": {}
},
"id": "28b6101d-e928-4861-a9e9-79209494b350",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "6. A Touch of Magic",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-5856,
1888
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 6 课:一点魔法(JS 函数)\n\n你不仅可以获取数据,还可以**操作和检查数据!**\n\n**表达式示例:**\n\n* **转换文本:** `{{ $('Source Data').last().json.name.toUpperCase() }}`\n* **数学运算:** `{{ Math.round($('Source Data').last().json.age / 7) }}`\n* **检查数据类型:** `{{ typeof $('Source Data').last().json.age }}`\n\n**解析:**\n\n* **`.toUpperCase()`**:字符串的标准 JavaScript 函数,用于转换为大写。\n* **`Math.round(...)`**:`Math` 对象提供强大的数学函数。\n* **`typeof`**:一个操作符,用于告诉你当前数据的类型(如 \"string\"、\"number\"、\"object\" 等)。\n",
"height": 520,
"width": 580,
"color": 3
},
"id": "8de28f31-6bb1-4ffd-939a-4e8c2ee55e21",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-6096,
1536
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "all_skills_string",
"type": "string",
"value": "={{ $('Split Out Skills').all().map(item => item.json.skills).join(', ') }}"
}
]
},
"options": {}
},
"id": "25d30efd-bc7f-4c82-9d86-dccedff189c5",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "9. The \"All Items\" View",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-6224,
2528
],
"executeOnce": true,
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 9 课:处理多个项目(`$items` 与箭头函数)\n\n如果一个节点输出*多个*项目,而你想对它们进行汇总,该用 `$items()`。\n\n**目标:** 获取所有用户技能,并合并成一个逗号分隔的字符串。\n\n**表达式:**\n`{{ $('Split Out Skills').all().map(item => item.json.skills).join(', ') }}`\n\n**什么是 `item => ...`?**\n这是**箭头函数(Arrow Function)**,是一种"对每个元素执行某个操作"的简写形式。\n\n* `item`:在循环中临时代表当前项目的变量名。\n* `=>`:箭头,用于分隔元素和要执行的操作。\n* `item.json.skills`:要执行的操作------这里是从每个项目中获取技能值。\n",
"height": 520,
"width": 780,
"color": 5
},
"id": "20a16659-dba5-4875-a622-4eab3751340c",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-6656,
2176
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "final_summary",
"type": "string",
"value": "=User {{ $('2. The n8n Selectors').last().json.user_name_from_first }} is {{ $('Source Data').last().json.age }}.\n\nTheir best skill is {{ $('3. Working with Arrays').last().json.second_skill }}.\n\nTheir first project was {{ $('Source Data').last().json.projects[0].name }}, which is now {{ $('5. The Combo Move').last().json.first_project_status }}.\n\nAll skills: {{ $('9. The \"All Items\" View').last().json.all_skills_string }}."
}
]
},
"options": {}
},
"id": "694a1dde-3433-4eca-a8fc-dbef1e48735c",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Final Exam",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-5648,
2528
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 🎓 期末考试:综合应用\n\n这个节点运用我们学过的所有知识,构建了一个最终的汇总对象。\n\n查看每个字段的表达式,它们从不同的节点获取数据,并使用了你刚刚练习过的各种技巧。\n\n**恭喜!你现在已经具备了在 n8n 中关联数据并构建强大动态工作流的基础知识。**\n",
"height": 420,
"width": 520,
"color": 6
},
"id": "dfef477b-e53f-40fd-ae4d-8cff4a182f99",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-5856,
2272
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "user_name_from_first",
"type": "string",
"value": "={{ $('Source Data').last().json.name }}"
}
]
},
"options": {}
},
"id": "b52f1c10-4485-46c0-a840-cd8af23b3f3c",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "2. The n8n Selectors",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-5888,
1296
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 2 课:n8n 选择器(`.first()`、`.last()`、`.all()`)\n\n在上一课中,我们使用了 `.item`。当一个节点只输出一个项目时,这等同于 `.last()`。显式使用 `.last()` 往往更安全、更清晰。\n\n**目标:** 使用 `.last()` 选择器获取用户姓名。\n\n**表达式:** `{{ $('Source Data').last().json.name }}`\n\n**为什么这样更好?**\n如果一个节点返回多个项目,`.last()` 可以保证你只获取最后一个项目的数据。\n\n如果你需要将选中的数据与输入项目匹配,这时 `.item` 是无法替代的。\n\n**其他选择器:**\n\n* **`.first()`**:获取第一个项目的数据。\n* **`.all()`**:获取所有项目的数据,返回为对象数组。(这与 `$items` 不同!)\n",
"height": 620,
"width": 680
},
"id": "2d4f69ac-8c9a-40f9-b14a-320934b7ce46",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-6192,
832
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "contact_keys",
"type": "array",
"value": "={{ Object.keys($('Source Data').last().json.contact) }}"
}
]
},
"options": {}
},
"id": "cdecf4df-3bb9-4eda-929e-1de8a7a014e1",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "7. Inspecting Objects",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-5296,
1888
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 7 课:检查对象(`Object.keys()`)\n\n如果你有一个对象,但不知道里面有哪些键,该怎么办?`Object.keys()` 就能派上用场。\n\n**目标:** 获取 `contact` 对象中所有键的列表。\n\n**表达式:** `{{ Object.keys($('Source Data').last().json.contact) }}`\n\n这在动态处理数据时非常有用。它会返回一个**数组**,包含所有键的名称(例如 `[\"email\", \"phone\"]`)。\n",
"height": 520,
"width": 500,
"color": 2
},
"id": "e4bbccfc-f961-48aa-ab9c-07611db2673a",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-5488,
1536
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "12345",
"name": "contact_as_string",
"type": "string",
"value": "={{ JSON.stringify($('Source Data').last().json.contact, null, 2) }}"
},
{
"id": "06003b65-7482-4d5a-b2c0-1794859ab461",
"name": "skills",
"type": "array",
"value": "={{ $('Source Data').last().json.skills }}"
}
]
},
"options": {}
},
"id": "71d6e5b3-1f2b-4bb9-98e7-3567f1a2ca1b",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "8. Utility Functions",
"type": "n8n-nodes-base.set",
"creator": "Lucas Peyrin",
"position": [
-7024,
2528
],
"typeVersion": 3.4,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"content": "## 第 8 课:实用函数(`JSON.stringify()`)\n\n有时你需要将结构化的 JSON 对象转换回一个干净的单行字符串。这在向其他服务发送数据时很常见,比如在 AI 提示中。\n\n**目标:** 将整个 `contact` 对象转换为格式化字符串。\n\n**表达式:** `{{ JSON.stringify($('Source Data').last().json.contact, null, 2) }}`\n\n**解析:**\n\n* **`JSON.stringify(...)`**:执行转换的函数。\n* **`null, 2`**:可选参数,用于"美化输出",在字符串中添加 2 个空格缩进,使其更易读。\n",
"height": 520,
"width": 580
},
"id": "ee5dd956-f793-4b65-8b83-2e92ed163eca",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Sticky Note11",
"type": "n8n-nodes-base.stickyNote",
"creator": "Lucas Peyrin",
"position": [
-7264,
2176
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
},
{
"parameters": {
"fieldToSplitOut": "skills",
"include": "allOtherFields",
"options": {}
},
"id": "9a32fe97-a67f-4d87-84cb-a9b448c9e5bc",
"cid": "Ikx1Y2FzIFBleXJpbiI",
"name": "Split Out Skills",
"type": "n8n-nodes-base.splitOut",
"creator": "Lucas Peyrin",
"position": [
-6448,
2528
],
"typeVersion": 1,
"notes": "© 2025 BigTT"
}
],
"pinData": {},
"connections": {
"Source Data": {
"main": [
[
{
"node": "1. The Basics",
"type": "main",
"index": 0
}
]
]
},
"1. The Basics": {
"main": [
[
{
"node": "2. The n8n Selectors",
"type": "main",
"index": 0
}
]
]
},
"Start Tutorial": {
"main": [
[
{
"node": "Source Data",
"type": "main",
"index": 0
}
]
]
},
"4. Going Deeper": {
"main": [
[
{
"node": "5. The Combo Move",
"type": "main",
"index": 0
}
]
]
},
"Split Out Skills": {
"main": [
[
{
"node": "9. The \"All Items\" View",
"type": "main",
"index": 0
}
]
]
},
"5. The Combo Move": {
"main": [
[
{
"node": "6. A Touch of Magic",
"type": "main",
"index": 0
}
]
]
},
"6. A Touch of Magic": {
"main": [
[
{
"node": "7. Inspecting Objects",
"type": "main",
"index": 0
}
]
]
},
"2. The n8n Selectors": {
"main": [
[
{
"node": "3. Working with Arrays",
"type": "main",
"index": 0
}
]
]
},
"8. Utility Functions": {
"main": [
[
{
"node": "Split Out Skills",
"type": "main",
"index": 0
}
]
]
},
"7. Inspecting Objects": {
"main": [
[
{
"node": "8. Utility Functions",
"type": "main",
"index": 0
}
]
]
},
"3. Working with Arrays": {
"main": [
[
{
"node": "4. Going Deeper",
"type": "main",
"index": 0
}
]
]
},
"9. The \"All Items\" View": {
"main": [
[
{
"node": "Final Exam",
"type": "main",
"index": 0
}
]
]
},
"Final Exam": {
"main": [
[]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "8cb3f189-d515-4fce-95ac-5588134b0a00",
"meta": {
"instanceId": "54c9e2e31753f3c874da48cdbf9552e23a88fbc2e067ac67b23af8418a890097"
},
"id": "Ga70tswUAlRwzwYa",
"tags": []
}