You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One larger area of configurability where users have very different views of defaults is that of whether and when allow coercions from non-canonical shapes.
For example, some users would like following POJO:
publicclassBean {
publicbooleanvalue;
}
to be only readable from JSON like
{ "value" : true }
whereas others would want to accept
{ "value" : "true" }
or even
{"value" : 1 }
Agreeing on defaults is challenging, but historically Jackson has been using more permissive defaults due to user feedback (requests to allow alternate shapes to be accepted).
Conversely other users who prefer more rigid validation have requested ability to prevent coercions, resulting in things like:
MapperFeature.ALLOW_COERCION_OF_SCALARS (global setting) // originally just for primitive numebrs
@JsonFormat(lenient = false) // originally just for Date/Time
ConfigOverride mechanism for JsonFormat.Value
But while these can help a bit, there are issues like:
Global applicability (one size fits all)
No separation for different input shapes (everything allowed (very loose) or just primary (very strict))
Does not differentiate "empty" values either as input (do we allow "", { }, [ ]), or as result (Java [ ], new ArrayList<>(), new HashMap<>())
Given this, I am thinking of implementing configuration scheme that is modeled much like ConfigOverrides, but is more specialized with mapping combination of "target type"/"input shape" into resulting action (fail, coerce into null/empty/value).
Mapping of target type should allow both general type categories ("integral number", "POJO/Bean") and specific type/class (java.util.UUID) for convenience.
Target action has to be figured out since there is difference between mapping "empty" values (typically becomes null, "empty" or "fail") and "regular" values (real coercion from String "true" into boolean true, for example)
The text was updated successfully, but these errors were encountered:
One larger area of configurability where users have very different views of defaults is that of whether and when allow coercions from non-canonical shapes.
For example, some users would like following POJO:
to be only readable from JSON like
whereas others would want to accept
or even
Agreeing on defaults is challenging, but historically Jackson has been using more permissive defaults due to user feedback (requests to allow alternate shapes to be accepted).
Conversely other users who prefer more rigid validation have requested ability to prevent coercions, resulting in things like:
MapperFeature.ALLOW_COERCION_OF_SCALARS
(global setting) // originally just for primitive numebrs@JsonFormat(lenient = false)
// originally just for Date/TimeConfigOverride
mechanism forJsonFormat.Value
But while these can help a bit, there are issues like:
{ }
,[ ]
), or as result (Java[ ]
,new ArrayList<>()
,new HashMap<>()
)Given this, I am thinking of implementing configuration scheme that is modeled much like
ConfigOverrides
, but is more specialized with mapping combination of "target type"/"input shape" into resulting action (fail, coerce into null/empty/value).Mapping of target type should allow both general type categories ("integral number", "POJO/Bean") and specific type/class (
java.util.UUID
) for convenience.Target action has to be figured out since there is difference between mapping "empty" values (typically becomes
null
, "empty" or "fail") and "regular" values (real coercion from String "true" into booleantrue
, for example)The text was updated successfully, but these errors were encountered: