跳转到内容
Last updated

处理 JSON

节点类型 browser_processJson

功能说明

按选定方式转换 JSON 或提取其中的数据。

客户端配置界面

处理 JSON节点的客户端配置界面

截图来自 MoreLogin 桌面客户端 V2.73.101 的英文界面。

输入字段

以下字段位于 data.browserUi.inputs。

字段类型或取值Schema 必填执行默认值说明与边界
source["null","boolean","number","string"] / array<JSON> / object(支持变量引用)否—输入 JSON
dataType["null","boolean","number","string"] / array<JSON> / object(支持变量引用)否—数据类型
processingMode"display" / "organize" / "combine"(支持变量引用)是—处理方式
mergeSources["null","boolean","number","string"] / array<JSON> / object(支持变量引用)否—合并数据 编辑器初值 ["",""]
fieldMappingsarray<object>(支持变量引用)否—目标字段 编辑器初值 [{"key":"","from":"field","path":"","value":""}]
conflictPolicy"first" / "last" / string / null否—同名字段处理
showListboolean(支持变量引用)否true显示列表 编辑器初值 true
singleResult"first" / "random"(支持变量引用)否"first"选取结果 编辑器初值 "first"
dedupeEnabledboolean(支持变量引用)否false去重 编辑器初值 false
dedupeBy"whole" / "field"(支持变量引用)否"whole"去重方式 编辑器初值 "whole"
outputDedupeFieldstring否—去重字段路径
sortEnabledboolean(支持变量引用)否false排序 编辑器初值 false
sortBy"field"(支持变量引用)否"field"排序依据 编辑器初值 "field"
outputSortFieldstring否—排序字段路径
sortDirection"asc" / "desc" / string / null否—排序方向
resultPreview["null","boolean","number","string"] / array<JSON> / object(支持变量引用)否—结果预览

条件与边界

  • processingMode(必填,无默认值)=display/organize/combine:fieldMappings 按目标字段及来源路径重构;mergeSources 合并同类型对象/数组,conflictPolicy 指定同名字段策略;列表可去重、排序、选第一项/随机项。JSON 内引用保留类型并正确转义;缺失 JSON 引用替换空串。
  • 校验错误码 RPA_NODE_INPUT_INVALID
  • 必填 processingMode
  • 编辑器必填项,没有默认值;省略时写入与校验返回 RPA_NODE_INPUT_INVALID(reason=required),运行前同样拒绝。
  • 校验错误码 RPA_NODE_INPUT_INVALID

输入引用

字段允许的形式
sourceliteral, template
dataTypeliteral, template
processingModeliteral, template
mergeSourcesliteral, template
fieldMappingsliteral, template
conflictPolicyliteral, template
showListliteral, template
singleResultliteral, template
dedupeEnabledliteral, template
dedupeByliteral, template
outputDedupeFieldliteral, template
sortEnabledliteral, template
sortByliteral, template
outputSortFieldliteral, template
sortDirectionliteral, template
resultPreviewliteral, template

输出字段

输出字段类型或取值
value["null","boolean","number","string"] / array<JSON> / object
countnumber
indexnumber

按契约用 ${nodeId.data.field} 引用公开字段。

JSON 示例

可放入流程 nodes 数组或其他节点 blocks 中的完整节点对象。

{
  "id": "pick_names",
  "type": "browser_processJson",
  "data": {
    "title": "保留商品名称并添加币种",
    "browserAction": "processJson",
    "browserUi": {
      "inputs": {
        "source": [
          {
            "name": "Desk",
            "price": 120
          },
          {
            "name": "Chair",
            "price": 45
          }
        ],
        "processingMode": "organize",
        "fieldMappings": [
          {
            "key": "product",
            "from": "field",
            "path": "name"
          },
          {
            "key": "currency",
            "from": "fixed",
            "value": "USD"
          }
        ]
      },
      "exception": {
        "timeout": 30000,
        "policy": "interrupt"
      }
    }
  }
}

返回节点目录