-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 FasterXML#3013: Implement int-to-string coercion config #3608
Fix FasterXML#3013: Implement int-to-string coercion config #3608
Conversation
Note to self: we do have CLA for this. |
@@ -61,6 +62,15 @@ public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx | |||
if (t == JsonToken.START_OBJECT) { | |||
return ctxt.extractScalarFromObject(p, this, _valueClass); | |||
} | |||
if (t == JsonToken.VALUE_NUMBER_INT) { |
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.
Could this be simplified by calling _parseString(...)
and removing handling of START_OBJECT, VALUE_EMBEDDED_OBJECT (that are handled there)?
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.
Good one! Yes, it can. I've rewritten this method in terms of _parseString(...)
, leaving only the START_ARRAY
case in the original method and the VALUE_STRING
case at the very top as an optimization — I assume it is the most common case, so I figured it would make sense to keep that there even if it is already handled in _parseString(...)
. If you think this is a premature optimization, let me know and I'll remove it :-)
Looks good; I have one potential suggestion here, but happy to merge otherwise. |
I have implemented your suggestion. For some reason, the |
@Tomasito665 That is odd and I doubt it has anything to do with your changes. I actually ended up removing that test case since I do not think it adds any value (uses Mock objects to verify something that ... does not seem valuable). I'll see if I can get PR itself now reviewed. |
Ok, this looks good. I will need to go over it one more time, merge hopefully tomorrow, possibly making minor tweaks. |
@Tomasito665 I just merged this, so if you want to do another PR for coercion from Float etc, should be possible. Thank you again for contributing this! |
Wonderful, thanks for merging, @cowtowncoder. I wanted to add the method overload for |
Description
This pull request implements configurable integer to string coercion.
Issue
#3013