json-processing-spec
  1. json-processing-spec
  2. JSON_PROCESSING_SPEC-41

Remove NumberType.LONG and rename NumberType.BigDecimal

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-pr
    • Fix Version/s: 1.0-pr
    • Labels:
      None

      Description

      NumberType would be less confusing if it just stated the distinction whether a number has a fractional part.

      A NumberType of INTEGER would guarantee that calling getBigIntegerValue does not throw an ArithmeticException. The NumberType would be independent of the actual magnitude of the number, thus calling getIntValueExact might still throw an Exception if the number is smaller than Integer.MIN_VALUE of larger than Integer.MAX_VALUE.

      The current NumberType BIG_DECIMAL should be renamed to just DECIMAL or REAL (see http://en.wikipedia.org/wiki/Real_number) and would indicate that the number has a fractional part and calling get(Int|Long|BigInteger)ValueExact might throw an ArithmeticException.

      The algorithm for distinguishing these two types should be based on whether BigDecimal#scale() is 0.

      Discussion at http://java.net/projects/json-processing-spec/lists/users/archive/2012-12/message/43

        Activity

        jhorstmann created issue -
        jitu made changes -
        Field Original Value New Value
        Assignee jitu [ jitu ]
        Fix Version/s 1.0-pr [ 16133 ]
        Affects Version/s 1.0-pr [ 16133 ]
        jitu made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            jitu
            Reporter:
            jhorstmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: