简体   繁体   English

JOLT 转换 - 从字符串中删除前导零

[英]JOLT Transformation - Remove leading zeros from String

I have a example input:我有一个示例输入:

{
  "number": "0000000000068908"
}

or an other example input:或其他示例输入:

{
  "number": "0012000000034458"
}

Is it possible to remove the leading zeros from string via jolt transformation to get the following output?是否可以通过颠簸转换从字符串中删除前导零以获得以下 output?

{
  "number": "68908"
}

or或者

{
  "number": "12000000034458"
}

sorry for the late reply,there are several ways to reach that, one I can imagine is turn the string into a numeric value(eg a long int) after this, the zeros to the left will be removed, and then you can use that result and convert it to string again.抱歉回复晚了,有几种方法可以实现,我可以想象一种是在此之后将字符串转换为数值(例如 long int),左侧的零将被删除,然后你可以使用它结果并再次将其转换为字符串。

here you can play:在这里你可以玩:

http://jolt-demo.appspot.com/#modify-typeConversion http://jolt-demo.appspot.com/#modify-typeConversion

and here the demo: json:这里是演示:json:

{
  "number": "0000000000068908"
}

Jolt Spec:颠簸规格:

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "number": "=toLong"
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "number": "=toString"
    }
  }
]

result:结果:

{
  "number" : "68908"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM