-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Proposal to split scalar coercion into more granular features #4950
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
For backward compatibility, we should not change the existing ALLOW_COERCION_OF_SCALARS config. We can add more to support more granular control. Can you provide a detailed proposal or a stub PR? |
Note that For usage, |
Hi @pjfanning @cowtowncoder ! Thanks for your quick feedback and suggestions! I had a case where I needed to deserialize a String as BigDecimal, but I wanted to prevent converting int to boolean. When I found ALLOW_COERCION_OF_SCALARS, I encountered an issue. It fixed the problem with boolean values, but it stopped working for string conversions as well. To be honest, I didn't know about the possibilities of CoercionConfig. After reviewing the links you shared, I was able to set up exactly what I needed. Here’s a link with an example of the issue I ran into, along with tests showing how ALLOW_COERCION_OF_SCALARS didn’t work in my case, and how CoercionConfig helped. |
@ivamly Yes, documentation is still a weak area -- so much functionality exists that it is hard to know what all is available. Glad you were able to figure it out & thank you for sharing the link so other might find it too! |
@cowtowncoder Thank you! Should I close this issue, or are there any other actions I should take? |
I can close. Thanks! |
Is your feature request related to a problem? Please describe.
Currently, the ALLOW_COERCION_OF_SCALARS feature in MappingFeature allows coercions from secondary representations for simple scalar types.
However, there are cases where certain coercions can lead to unintended or undesirable behavior. For example:
Describe the solution you'd like
It would be beneficial to either:
This would provide users with finer control over deserialization behavior and greater flexibility for different use cases.
Usage example
No response
Additional context
If there is already a way to achieve this level of control with the current configuration options, I would appreciate further clarification.
The text was updated successfully, but these errors were encountered: