【问题标题】:JOLT Specification to Transform field value to field name将字段值转换为字段名称的 JOLT 规范
【发布时间】:2022-08-17 00:33:41
【问题描述】:

我正在尝试将以下 json 有效负载转换为具有字段名称作为字段值的 json 有效负载:

你能帮忙提供一下jold规范吗?

输入 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\"
}
}

输出有效载荷:

{
\"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\"
}
}

    标签: json jolt


    【解决方案1】:

    这将帮助您解决它。 @(level,attribute) --> 工作。

    [
      {
        "operation": "shift",
        "spec": {
          "action": {
            "*": "action.&",
            "records": {
              "*": {
                "ShipToCustomerTextualAddress__c": "action.records.@(1,recordid).&",
                "ResellerPO__c": "action.records.@(1,recordid).&",
                "InvoiceCDBID__c": "action.records.@(1,recordid).&"
              }
            }
          }
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 2022-01-19
      • 2016-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-16
      • 2021-01-09
      • 1970-01-01
      相关资源
      最近更新 更多