Details

Type: Improvement

Status: Resolved

Priority: Major

Resolution: Fixed

Affects Version/s: 1.0pr

Fix Version/s: 1.0pr

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(IntLongBigInteger)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/jsonprocessingspec/lists/users/archive/201212/message/43
Activity
Field  Original Value  New Value 

Assignee  jitu [ jitu ]  
Fix Version/s  1.0pr [ 16133 ]  
Affects Version/s  1.0pr [ 16133 ] 
Status  Open [ 1 ]  Resolved [ 5 ] 
Resolution  Fixed [ 1 ] 
On a Jave ME profile of this JSON API, the methods getBigIntegerValue(Exact) and getBigDecimalValue would be excluded, NumberType should be INTEGER if the number can be exactly represented as a long, which is the largest integral type on such platforms.