I have a file with some data and configuration parameters that i need to change before I use it as body data for POST rest call.
So I am using slurper to get the configuration value
JsonSlurper slurper = new JsonSlurper()
def inputFile = new File("file.json")
def parsedInput = slurper.parse(inputFile)
Then I change the desired configuration parameter
parsedInput.config.id = 1
And then modified input file is written to the temporary file
def tempFile = new File("temp.json")
tempFile.write(JsonOutput.toJson(parsedInput))
I was quite surprised when I realized that the output file is three times larger than the input. I have checked the content and it looks like slurper changed the float precision.
Before modification
0.145,
0.144,
0.145,
After modification
0.1459999999999999908961711980737163685262203216552734375,
0.1449999999999999900079927783735911361873149871826171875,
0.1459999999999999908961711980737163685262203216552734375
Any ideas how to fix it?
EDIT 1: added some input data