-
Notifications
You must be signed in to change notification settings - Fork 62
Support for numbers outside of IEEE754 double precision range #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
Please provide something like:
to process Double values in a correct and complete manner. Actually, Json-P does ignore valid information of a Double and is NOT able to produce The How should one know beforehand when a Something like this is actually impossible with Json-P and therefore also with Json-B:
I actually looked at what Jackson makes with such values. Jackson does what it should and can (de)serialize |
I think we should be able to resolve @nimo23 's comment by updating the Javadoc to remove the requirement that |
The JSON grammar does not allow RFC 8259 states:
The feature can be configured with an option WRITE_NAN_AS_STRINGS in Jackson. |
Thanks for pointing that out. I had assumed it was valid JSON as it was mentioned to work in Jackson. I suppose we could add an option to support this behavior, but that could reasonably also be done in individual implementations rather than mandated by the spec. We are getting somewhat sidetracked from the issue here so if you'd like you can open a separate issue for discussion on this @nimo23. |
JSONP is a low-level parser. I don't think that it should contain this kind of logic. IMO, it should be done on a higher level (read JSONB). |
@nimo23 JSONP writes numbers as it's defined in JSON RFC. "NaN" and "Infinity" are not numbers but strings from JSON perspective. The functionality you suggesting could be a part of higher level binding framework though. |
@m0mus yes, this is what I also think. Such things should be definitly go to Json-B, because B stands for Binding and actually the binding between java numbers and json processing is not complete. Therefore, I asked for that in eclipse-ee4j/yasson#306 before, but it was market as duplicated and closed with the reason that this should be done in lower level (json-p). Hence, I created I #209. But in my opinion, Json-B must support full binding of Numbers. |
@nimo23 I reopened eclipse-ee4j/yasson#306 |
Closing this issue. If someone wants to discuss it more -> reopen. |
The original subject of this issue and a pull request attached to it is completely different of what @nimo23 started to talk about. |
@bravehorsie I see this functionality unnecessary and I discussed it with you privately. If you need to write a number as string, JSONP has methods to write strings. |
JSONP API JsonGenerator / JsonParser types expose methods for reading / writing numbers which can contai values outside of IEEE754 double precision allows. These are:
java.math.BigDecimal
,java.math.BigInteger
andjava.lang.Long
Currently JSONP doesn't offer anything different than writing them as JSON number type. This may cause ECMAScript based parsers to loose precision when parsing these numbers. The proposal is to introduce a "big number strategy" into JSONP API which will allow users to configure how to handle these numbers.
This configuration should be propagated through
javax.json.stream.JsonGeneratorFactory
/javax.json.stream.JsonParserFactory
, which contains other configuration mapping such asJsonGenerator.PRETTY_PRINTING
. The default strategy to use should be JSON_NUMBER.References:
[1] https://www.ecma-international.org/ecma-262/9.0/index.html#sec-ecmascript-language-types-number-type
[2] jakartaee/jsonb-api#112
[3] https://github.com/cyberphone/I-JSON-Number-System#java-json-b
[4] https://github.com/eclipse-ee4j/yasson/blob/master/src/main/java/org/eclipse/yasson/internal/serializer/BigNumberUtil.java
The text was updated successfully, but these errors were encountered: