activities
latest
false
- 概述
- 加密
- 数据库
- Java
- Python
- 网页 API
开发者活动
上次更新日期 2026年4月21日
以下示例说明了如何使用“调用代码”和“反序列化 JSON 数组”等活动来创建 JSON 数组,将其反序列化,并提供提取的令牌的列表。您可以在“UiPath.WebAPI.Activities ”包中找到这些活动。
此自动化流程的构建方法如下:
-
打开 Studio ,创建一个新“流程”。
-
将“序列”容器拖动至“工作流设计器”。
-
创建以下变量:
变量名称 变量类型 默认值 jsonAsString字符串 jsonAsArray数组 -
Add an Invoke Code activity inside the Sequence.
-
选择“编辑代码”按钮,并在打开的窗口中添加以下代码:
Dim obj As ArrayList = New ArrayList() obj.Add("Starcraft") obj.Add("DOTA 2") obj.Add("FarCry") Out = JsonConvert.SerializeObject(obj)Dim obj As ArrayList = New ArrayList() obj.Add("Starcraft") obj.Add("DOTA 2") obj.Add("FarCry") Out = JsonConvert.SerializeObject(obj) -
添加代码后,选择“确定”按钮。
-
Select the Edit Arguments button and add the following argument:
参数 方向 类型 值 out输出 字符串 jsonAsString -
完成后,选择“确定”按钮,如以下动图所示:

-
-
将“日志消息”活动拖动到“调用代码”活动之后。
- 在“行”字段中添加表达式“
"JSON As String: "+jsonAsString”。
- 在“行”字段中添加表达式“
-
在“日志消息”活动之后添加“反序列化 JSON 数组”活动。
- Add the variable
jsonAsStringin the Json String field. - In the Properties panel, add the variable
jsonAsArrayin the JsonArray field.
- Add the variable
-
将“遍历循环”活动添加到“反序列化 JSON 数组”活动之后。
- Add the value
tokenin the ForEach field. - 在“VB 表达式”字段中添加
jsonAsArray变量。 - In the Properties panel, in the TypeArgument field, make sure you chose JValue.
- Add the value
-
Add a Log Message activity inside the Body of the For Each activity.
- 在“行”字段中添加表达式“
token.ToString”。
您的工作流应如下所示:

- 在“行”字段中添加表达式“
-
运行流程。 系统将创建一个 JSON 数组,将其反序列化为字符串,并作为提取的令牌列表提供。
您可在此处下载示例。