-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
(note: result of #5417)
Jackson 3.0 changed coercion behavior for existing 2.x methods such as asString(String defValue) for NullNodes (mapped from explicit JSON null values) so that instead of returning defValue, they coerce into "empty" value of type -- in case of asString(), empty String "". In 2.x, matching method (named asText()) returned defValue.
Similarly new Optional<String> asStringOpt() returns new Optional<String>("") instead Optional.empty().
This applies consistently across all various asXxx() and asXxxOpt() methods, for NullNodes.
Note: problem does not affect MissingNode. Also, plain asString() coerces NullNode into "", and this is expected due to lack of defaulting.
Based on Strong developer feedback, we should change the behavior of NullNode so that following is true:
asXxx()will coerce into default/empty value of typeXxx: "" forStrings,0forInts,falseforBooleanand so on. THIS IS EXISTING BEHAVIOR of 3.0 (no change)asXxx(Xxx defValue)will simply returndefValue. THIS IS CHANGINGasXxxOpt()will simply return "missing" optional:Optional.empty(),OptionalInt.empty()and so on. THIS IS CHANGING
Note: no changes suggested for behavior of non-coercing accessors (xxxValue(), xxxValue(defValue), xxxValueOpt() -- stringValue(), stringValue(String defValue), Optional<String> stringValueOpt()