Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7794

JsonSlurper is dropping precision of decimal numbers ending in 0 after the decimal point

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: JSON
    • Labels:
      None

      Description

      When parsing JSON documents with numbers that end in a zero after the decimal point, JsonSlurper is not correctly setting the scale.

      For example, when run in groovysh:

      groovy:000> (1234.0).scale
      ===> 1
      groovy:000> import groovy.json.JsonSlurper
      ===> groovy.json.JsonSlurper
      groovy:000> new JsonSlurper().parseText('1234.0').scale
      ===> 0
      groovy:000> (1234.10).scale
      ===> 2
      groovy:000> new JsonSlurper().parseText('1234.10').scale
      ===> 1

      This was found in Groovy versions 2.4.3 and 2.4.4.

      For a result of this, please refer to https://github.com/DiUS/pact-jvm/issues/221

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              uglyog@gmail.com Ronald Holshausen
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: