繁体   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