簡體   English   中英

顛簸變換

[英]Jolt Transformation

我正在嘗試為以下輸入編寫顛簸轉換-

{ 
 "restaurantId": "ZZ4ORJDY3E",  
 "chainId": "a-b"
}

預期輸出為-

{
 "ZZ4ORJDY3E" : {
   "key" : "ZZ4ORJDY3E",
   "start" : "a",
   "end" : "b"
  }
}

我的規格是-

[
  {
    "operation": "shift",
    "spec": {
      "@restaurantId": "@restaurantId.key",
      "chainId": {
        "*-*": {
          "$(0,1)": "@restaurantId.start",
          "$(0,2)": "@restaurantId.end"
        }
      }
    }
  }
]

規格未按預期輸出轉換。 我想學習如何在字符串解析器中使用屬性。

規格

[
  {
    "operation": "shift",
    "spec": {
      "restaurantId": {
        // match any value of restaurantId
        "*": {
          // write the value to of the key $ to the output
          // where the output is the "value of the key".key
          // kinda hokey
          "$": "&.key"
        }
      },
      "chainId": {
        "*-*": {
          // write each part of the chainId to the output
          //  at the value of restaurantId from back up the tree
          "$(0,1)": "@(3,restaurantId).start",
          "$(0,2)": "@(3,restaurantId).end"
        }
      }
    }
  }
]

暫無
暫無

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

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