-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Double value 0.0 getting deserialized as 0 with Tree Model (JsonNode
)
#1568
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
@anjaliguptaz Please provide code example of what exactly you are doing: description does not really give many details (POJO or |
Can not reproduce; may be reopened with a unit test or similar reproduction (on 2.8.7 or 2.9.0.pr2) |
I just ran into the same issue. There is a difference in behaviour between readTree and readValue. readValue behaves as expected, readTree returns the incorrect 0.
Output:
The difference is in that
There seems to be a flag to suppress this behaviour, but I've not been able to find how to set this flag. I'm not the original poster, so I can't re-open this issue... |
@cowtowncoder : Should I create a new issue, or can you re-open this one? |
Hmmh. Interesting. Ok, Not quite sure any more what the logic for comparison here is, but would seem like instead of |
I hope this makes sense on this one -- this weeks been tough For decimal from BigDecimal what I think i've found is you need to set the scale/precision manually to go into decimal() with 0.0? So can either use .double(), or set the precision and scale on big decimal before going into decimal() Got a quick example below where I think it shows how it all comes together and difference of .double() vs .decimal()
|
@hylkevds Ok so there's bit more to the story, as you can see from Intent here is/was to make Special case of For Jackson 3.0 we can improve this:
by making it configurable (I added one feature there). Or who knows, maybe some work can be brought back to But right now I don't think I can actually change the default behavior, so configuring |
Setting a NodeFactory with the excactBigDecimals flag set works 👍
I had been looking for a configuration option, and hadn't noticed the setNodeFactory method. Having a configuration option would be nice. Especially since there are already two static instances created for both behaviours. In the meantime, I think it would help if some documentation is added to the What the default behaviour is doesn't matter much, as long as it's configurable, but personally I think that having |
@hylkevds Good idea wrt javadocs. I can see how different behavior seems confusing, depending on one's POV. I have been struggling with the fact that Tree Model ( So I will need to make a note on that for "change[d] defaults for 3.0" |
Jackson has inconsistent default behaviour. See FasterXML/jackson-databind#1568
Related to possible "node-config", see JSTEP-3 (https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-3), tagging as such. |
simple test that show this problem
result:
I found that DoubleNode compared VS DecimalNode, but equals (in both classes) doesn't support comparing against other classes:
so if one node DoubleNode and another DecimalNode - we will have equals = false |
JsonNode
)
Not quite clear what the ask is; closing, may be re-filed with clear explanation & considering all current (2.19) configurability via |
I was using Jackson version 2.6 and came across the issue where the 0.0 double is thrown away during deserialization (#849 )
So i upgraded to Jackson version 2.7 .Now the double value is there but 0.0 is getting deserialized as 0.
Any help on how to solve this is much appreciated .
The text was updated successfully, but these errors were encountered: