Description
When using the JsonParserType.CHARACTER_SOURCE decimal numbers are first parsed to double value and that value is used to construct the BigDecimal to return. This can produce some unexpected results.
For example:
import groovy.json.* def parser = new JsonSlurper().setType(JsonParserType.CHARACTER_SOURCE) def json = parser.parseText('{"num": 123.40}') assert json.num instanceof BigDecimal assert 123.40G == json.num
Fails with:
Assertion failed: assert 123.40G == json.num | | | | | 123.400000000000005684341886080801486968994140625 | [num:123.400000000000005684341886080801486968994140625] false at Script1.run(Script1.groovy:8)