bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.54k stars 328 forks source link

Add ability to zero-pad values #1152

Open cserroul opened 2 years ago

cserroul commented 2 years ago

Hey Jolt team,

I recently had a project where this was exactly the package that I needed but it was missing some functionality. What I needed was the ability to zero pad monetary values to a specified number of decimal places. So I could take something like this:

{ "bookValue": "123.4", "interestRate": "0.1" }

and convert it to

{ "bookValue": "123.40", "interestRate": "0.10000" }

The function that I added was called decimalPad and operated similar to rightPad but checked for the presence of a decimal place and then added the specified number of 0s required. If anyone else feels this type of feature would be useful, I'd be happy to make it a little more rigorous and put in a PR.