-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
3.0Issue planned for initial 3.0 releaseIssue planned for initial 3.0 release
Milestone
Description
(note: continuation of #4958 and #4991 )
Jackson 2.x has methods like JsonNode.asInt()
to allow some additional coercions from types not directly compatible (int
only coercible from JSON Numbers):
asInt()
similar tointValue()
but allows coercion from (compatible)String
, as well as null (and even Boolean?). But if not, throw exceptionasIntOpt()
likeasInt()
but returnsOptionalInt
, either present (as perasInt()
) or absent (instead of exception)
but as with JsonNode.xxxValue()
methods like intValue()
, no exception is thrown but quietly default value (like 0
for int
) is returned. For Jackson 3.0 we have unchecked JsonNodeException
so use that instead.
We can also clarify coercions that are allowed, as well as extend set of asXxx()
methods as it makes sense.
Types/methods to handle:
asDecimal()
(BigDecimal
)asDouble()
asInt()
asLong()
but let's also add
asBigInteger()
(probably not asFloat()
or asShort()
or asByte()
)
Metadata
Metadata
Assignees
Labels
3.0Issue planned for initial 3.0 releaseIssue planned for initial 3.0 release