[ https://issues.apache.org/jira/browse/GROOVY-6922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14997590#comment-14997590 ]
ASF GitHub Bot commented on GROOVY-6922: ---------------------------------------- GitHub user jwagenleitner opened a pull request: https://github.com/apache/incubator-groovy/pull/184 GROOVY-6922 - JsonSlurper loses trailing 0's in numbers This change is dependent on the change made in commit 84467fddc64744cc05d2b91b8704c753a9fb3d04 in master to the [CharScanner#parseBigDecimal(char[],int,int)] (https://github.com/apache/incubator-groovy/commit/84467fddc64744cc05d2b91b8704c753a9fb3d04#diff-d0df59d6b1bac924a44389e6b41aac99R687) method. The code being replaced looked like it was code left over from when the method returned a double for decimal values. This change uses the [BigDecimal(char[],int,int)] (http://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#BigDecimal(char[],%20int,%20int)) constructor (available since 1.5) for parsing of the decimal string and also eliminates the new String object allocations. You can merge this pull request into a Git repository by running: $ git pull https://github.com/jwagenleitner/incubator-groovy GROOVY-6922 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-groovy/pull/184.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #184 ---- commit 75a037c9ff26265790599bfd1d010ad75c6d5b70 Author: John Wagenleitner <john.wagenleit...@gmail.com> Date: 2015-11-07T20:50:14Z GROOVY-6922 - JsonSlurper loses trailing 0's in numbers ---- > JsonSlurper loses trailing 0's in numbers (regression in Groovy 2.3) > -------------------------------------------------------------------- > > Key: GROOVY-6922 > URL: https://issues.apache.org/jira/browse/GROOVY-6922 > Project: Groovy > Issue Type: Bug > Components: JSON > Affects Versions: 2.3.0, 2.4.3 > Reporter: Craig > > In previous versions of Grails before JsonSlurper was significantly changed, > this test passed. However, it fails in Groovy 2.3.x (tested up to 2.3.3). > {code} > void testParseNumWithDecimals() { > def i = parser.parseText('123.40') > BigDecimal i2 = 123.40G > assert i instanceof BigDecimal > assert i == i2 > } > {code} > This test should be added to > https://github.com/groovy/groovy-core/blob/GROOVY_2_3_X/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperTest.groovy > In Groovy 2.3.3, the assertion fails as i = 123.4G, not 123.40G. -- This message was sent by Atlassian JIRA (v6.3.4#6332)