簡體   English   中英

Jolt Transformation 使用 JSON 中的現有值添加新的關鍵字段

[英]Jolt Transformation adding new key field using exisiting values in the JSON

輸入 JSON 是

{
  "name": "XYZ",
  "fields": [
    {
      "Code": "8000385",
      "Number": "9010005790",
      "docDate": "19-05-2022",
      "dueDate": "30-09-2022",
      "totValue": "209121.66",
      "taxAmt": "0",
      "docAmt": "3005797",
      "dueAmt": "3005797",
      "docType": "INV",
      "divCode": null,
      "finYear": "2022"
    }
  ]
}

預期的 output 是

{
  "name": "XYZ",
  "fields": [
    {
      "Code": "8000385",
      "Number": "9010005790",
      "docDate": "19-05-2022",
      "dueDate": "30-09-2022",
      "totValue": "209121.66",
      "taxAmt": "0",
      "docAmt": "3005797",
      "dueAmt": "3005797",
      "docType": "INV",
      "divCode": null,
      "finYear": "2022",
      "Key" : "8000385~9010005790~DOCX" // new field as concatenation of Code and Number
    }
  ]
}

您可以將修改轉換與concat function 一起使用,例如

[
  {
    "operation": "modify-default-beta",
    "spec": {
      "fields": {
        "*": {
          "Key": "=concat(@(1,Code),'~',@(1,Number),'~DOCX')"
        }
      }
    }
  }
]

http://jolt-demo.appspot.com/網站上的演示是:

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM