-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix: Use Big Decimal for Tree #135
Fix: Use Big Decimal for Tree #135
Conversation
jr-stree/src/main/java/com/fasterxml/jackson/jr/stree/JacksonJrsTreeCodec.java
Outdated
Show resolved
Hide resolved
jr-stree/src/main/java/com/fasterxml/jackson/jr/stree/JacksonJrsTreeCodec.java
Outdated
Show resolved
Hide resolved
023fd94
to
f3e98ff
Compare
I believe this is the best route of action we can change without changing the base API for |
Quick note: needs to go against |
@@ -50,6 +65,16 @@ private JrsValue nodeFrom(JsonParser p) throws IOException | |||
return JrsBoolean.FALSE; | |||
case JsonTokenId.ID_NUMBER_INT: | |||
case JsonTokenId.ID_NUMBER_FLOAT: | |||
final JsonParser.NumberType n = p.getNumberType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot use this method, have a look at jackson-databind JsonNodeDeserializer
(I think) for better version. Problem being that this method will coerce type because JSON has no native knowledge of optimal FP type to use.
jr-stree/src/main/java/com/fasterxml/jackson/jr/stree/JacksonJrsTreeCodec.java
Outdated
Show resolved
Hide resolved
protected final ObjectCodec _objectCodec; | ||
|
||
// @since 2.17 | ||
protected boolean _failOnDuplicateKeys; | ||
protected boolean _useBigDecimalForFloat; | ||
|
||
public JacksonJrsTreeCodec withFeature(JSON.Feature... features) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good idea to require separate configurability of tree codec when JSON
already has settings. There needs to be a way for codec to access those settings.
So why wouldn't this use the approach already added in #51?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My Initial concerns were that we need to use extensions, instead of already present classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tree codec is already added as an extension isn't it.
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/ReadAsBigDecimal90Test.java
Outdated
Show resolved
Hide resolved
I am confused: #51 already showed the way to pass JSON.Feature flags... why wouldn't that approached be used? Also: care must be taken when checking expected FP type; there have been lots of fine-tuning in |
56674a2
to
44c904c
Compare
Hi @cowtowncoder , I know about the other PR, but was hesitant to use Extension instead of already present constructs. Yes this can be done as you say (and i have made the changes for the same). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- will merge later today
@Shounaks Ahh! I finally understood what you meant -- if using Still, I think I will create a separate issue for deprecating that method so that tree codecs will rather be registered as extensions and not directly assigned as |
yes exactly!
Thanks! |
@@ -50,6 +59,9 @@ private JrsValue nodeFrom(JsonParser p) throws IOException | |||
return JrsBoolean.FALSE; | |||
case JsonTokenId.ID_NUMBER_INT: | |||
case JsonTokenId.ID_NUMBER_FLOAT: | |||
if (_useBigDecimalForDouble) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this has bug -- now all integer numbers become BigDecimal
s too. I'll fix it.
For Issue: #90