users@jsonp.java.net

Re: Number parsing methods on JsonParser

From: Kin-man Chung <kinman.chung_at_oracle.com>
Date: Mon, 31 Aug 2015 11:04:58 -0700

If you are happy with getting a JsonNumber from JsonParser, why can't
you get a JsonNumber first and then use JsonNUmber's methods?

By "have the methods from JsonNumber directly on JsonParser", do you
mean adding bigDecimalValue, bigIntergerValue, doubleValue etc methods
to JsonParser?

That would really bloat the API.

-Kin-man

On 8/30/15 5:32 AM, Philippe Marschall wrote:
> Hi
>
> We would like to have the number parsing methods from JsonNumber on
> JsonParser.
>
> To explain our problem: we're currently parsing numbers into long and
> int. The options we have with 1.0 are not all that great:
> - use JsonReader and JsonNumber (#isIntegral and #exact)
> - use JsonParser and use BigDecimal
> - use JsonParser and live with silent data truncation
>
> All these options are not great. We would like to be able to use
> JsonParser without having to go through BigDecimal and without data
> truncation.
> The current 1.1 API helps a bit because it gives us JsonNumber on
> JsonParser but ideally we'd like to have the methods from JsonNumber
> directly on JsonParser.
>
> Cheers
> Philippe