boonproject / boon

Simple opinionated Java for the novice to expert level Java Programmer. Low Ceremony. High Productivity.
http://richardhightower.github.io/site/Boon/Welcome.html
Apache License 2.0
522 stars 102 forks source link

Parsing to BigInteger and BigDecimal is not supported #321

Open james-hu opened 9 years ago

james-hu commented 9 years ago

The code in NumberValue.java is:

    private final Object doToValue () {

        switch ( type ) {
            case DOUBLE:
            case DOUBLE_WRAPPER:
                return doubleValue ();
            case INT:
            case INTEGER_WRAPPER:

                if ( isInteger ( buffer, startIndex, endIndex - startIndex ) ) {
                    return intValue ();
                } else {
                    return longValue ();
                }
        }
        die ();
        return null;
    }

If the number is very long, for example, 997657654534536567567098675564232435535656766576876899, the deserialized object will be of Long type and probably (at least in this case) with a value of zero.

RichardHightower commented 9 years ago

You are correct. 997657654534536567567098675564232435535656766576876899 is a very long number. It could be the case that if you map it to a Java object that has a bignumber property that it does work. Look at Conversion.java. It would get handled there if it is handled. It might be. If it is not, we do accept pull requests.