Reputation: 39
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 ?
{
"number": "68908"
}
or
{
"number": "12000000034458"
}
Upvotes: 1
Views: 583
Reputation: 48278
sorry for the late reply,there are several ways to reach that, one I can imagine is turn the string into a numeric value(e.g. 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.
here you can play:
http://jolt-demo.appspot.com/#modify-typeConversion
and here the demo: json:
{
"number": "0000000000068908"
}
Jolt Spec:
[
{
"operation": "modify-overwrite-beta",
"spec": {
"number": "=toLong"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"number": "=toString"
}
}
]
result:
{
"number" : "68908"
}
Upvotes: 1