-
-
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
Add CoercionConfig[s]
mechanism for configuring allowed coercions
#2113
Comments
May need figure out what to try to get done for 2.10, considering that there is now also:
Also: need to figure out precedence of 1 a Global leniency: baseline where both 1a and 1b need to be enable to allow coercion. |
I actually have bit better idea now; something like |
@JsonFormat.lenient
to force strict (or not) handling of scalarsCoercionConfig[s]
mechanism for configuring allowed coercions
I have now implemented system in which per-mapper Four
Input shapes are defined with Target type is specific both by concrete (specific type), Rules can be targeted at 3 levels:
This feature allows defining coercion rules like:
|
… lots of work to make deserializer implementations use it.
One additional note: the main configuration system has been implemented, as well as support in There is also the question of deprecating of legacy settings (some |
One of recurring themes regarding handling of simple scalar values (like numbers, Enums) is that some users want strict handling (only accept values with exactly matching types; JSON boolean for Java boolean), whereas others prefer coercions that may accept "close enough" matches (for example, accepting number
0
to map asfalse
for Javaboolean
property).Right now configurability is both limited and global: main mechanism is
MapperFeature.ALLOW_COERCION_OF_SCALARS
; and there areDeserializationFeature
s likeFAIL_ON_NULL_FOR_PRIMITIVES
,FAIL_ON_NUMBERS_FOR_ENUMS
.But we could and should make use of another existing configuration mechanism:
@JsonFormat
has propertylenient
, which, if set tofalse
, could indicate strict handling.This setting is actually already used for Date/Time values, but as format feature it is already accessible, and can be configured:
thus allowing much more fine-grained setting.
We could and should start with:
Note, too, that since default for property is
OptBoolean.DEFAULT
, we can even distinguish between "lenient" / "not lenient" / "default", to allow further coercions, and leaving current set as "default" choice.The text was updated successfully, but these errors were encountered: