activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

开发者活动

上次更新日期 2025年9月29日

反序列化 JSON

UiPath.WebAPI.Activities.DeserializeJson

描述

将 JSON 字符串或示例反序列化为 JObject。

项目兼容性

Windows - 旧版 | Windows | 跨平台

Windows、跨平台配置

  • JSON 字符串 - 此为包含要反序列化的 JSON 数组的字符串。应在无缩进的情况下在双引号之间编写 JSON。JSON 中的字符串应使用单引号编写。下例展示了有效的 JSON:“{'TenancyName': 'Documentation', 'UsernameOrEmail': 'Documentation', 'Password': 'Documentation'}”。

  • JSON 示例- 输出结构的 JSON 示例。 该活动会将此示例转换为您可以在设计时使用的类似对象。
高级选项
输入
  • 输入类型”-此为下拉列表,用于从中选择要反序列化的对象的参数类型。
    Note: In Studio Web, parsing the sample object via the JSON Sample property makes the Input Type property read-only.

输出

Windows - 旧版配置

属性面板

常见

  • “显示名称”- 活动的显示名称。

输入

  • JSON 示例- 输出结构的 JSON 示例。 该活动会将此示例转换为您可以在设计时使用的类似对象。

  • JsonString - The string containing the JSON to be deserialized. Write the JSON without indents, and between double quotes. Strings inside the JSON should be written with single quotes. For example, the following JSON is valid: "{'TenancyName': 'Documentation', 'UsernameOrEmail': 'Documentation', 'Password': 'Documentation'}".

其他

  • “私有”- 选中后将不再以“Verbose”级别记录变量和参数的值。
  • 类型参数” - 此为下拉列表,用于从中选择返回的输出类型。 系统会将所提供的 JSON 字符串转换为所选类型的对象。

输出

使用“反序列化 Json”活动的示例

The Deserialize Json activity is used for extracting data from JSON files and strings.

To exemplify how to use this activity, we have created an example that uses the Deserialize Json activity for extracting the age of a person from a JSON file.

此自动化流程的构建方法如下:

  1. 打开 Studio ,创建一个新“流程”
  2. 序列活动拖动至“工作流设计器”。

    • 创建以下变量:

      变量名称

      变量类型

      默认值

      JsonText

      字符串

       

      JsonObj

      JObject

       

      Age

      泛型值

       
  3. 读取文本文件活动拖动至序列容器中。

    • 属性面板中,向文件名字段添加值 "JsonString.txt"
    • 在“内容”字段中添加“JsonText”变量。
  4. 将“反序列化 JSON”活动添加到“读取文本文件”活动之后。

    • 在“ 属性 ” 面板中,在“ JsonString” 字段中添加变量 JsonText ,在“ JsonObject ” 字段中添加变量 JsonObj
    • 类型参数下拉列表中选择 Newtonsoft.Json.Linq.JObject 值。
  5. 将“ 分配 ”活动放置在“ 反序列化 JSON ”活动下。

    • 目标字段中添加 Age 变量,并在字段中添加 JsonObj.SelectToken("age").ToString 表达式。
  6. 将“写入行”活动拖动到“分配”活动之后。

    • 在“文本”字段中添加“Age”变量。
  7. 运行流程。 机器人从 .json 文件中提取年龄值,并将其显示在“ 输出 ”面板中。

您可以在此处 下载示例。

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2025 UiPath。保留所有权利。