You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求JOLT规范:将JSON数组字段值转换为对象键名

JOLT转换规则:将records数组转为以recordid为键的对象

输入JSON

{"action": {"allowPartialSuccess": false,"records": [{"recordid": "a4c6364e-4446-47d0-b014-c20ca014fdb3","ShipToCustomerTextualAddress__c": "TestAddress1","ResellerPO__c": "TestAddress1","InvoiceCDBID__c": "TestAddress1"},{"recordid": "73781a94-9660-4f69-9bde-f2bf1991317d","ShipToCustomerTextualAddress__c": "TestAddress2","ResellerPO__c": "TestAddress2","InvoiceCDBID__c": "TestAddress2"}],"type": "update"}}

期望输出JSON

{"action": {"allowPartialSuccess": false,"records": {"a4c6364e-4446-47d0-b014-c20ca014fdb3": {"ShipToCustomerTextualAddress__c": "TestAddress1","ResellerPO__c": "TestAddress1","InvoiceCDBID__c": "TestAddress1"},"73781a94-9660-4f69-9bde-f2bf1991317d": {"ShipToCustomerTextualAddress__c": "TestAddress2","ResellerPO__c": "TestAddress2","InvoiceCDBID__c": "TestAddress2"}},"type": "update"}}

对应的JOLT转换规格

[
  {
    "operation": "shift",
    "spec": {
      "action": {
        "allowPartialSuccess": "action.allowPartialSuccess",
        "type": "action.type",
        "records": {
          "*": {
            "recordid": {
              "@(2)": "action.records.&"
            }
          }
        }
      }
    }
  },
  {
    "operation": "remove",
    "spec": {
      "action": {
        "records": {
          "*": {
            "recordid": ""
          }
        }
      }
    }
  }
]

规则说明

  • Shift操作:遍历action.records数组的每个元素,以元素的recordid值作为键,将整个元素映射到action.records下的对应键位置,同时保留allowPartialSuccess和type字段不变。
  • Remove操作:清除每个目标对象里的recordid字段,只保留业务相关字段。

内容的提问来源于stack exchange,提问作者Nitinamg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 18:09:18