-
Notifications
You must be signed in to change notification settings - Fork 175
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
objectMapper.treeToValue is error-prone, should be either deprecated or fixed (or removed?) #496
Comments
Huh, I've never used |
@Fuud why is this in Kotlin module? If it's about I am also not quite certain I understand why you claim However: I'd be +1 for adding overloads where type can be passed as Note, also, that |
There is no such problem in core jackson library because it is clean signature there: treeToValue
It is clear that type erasure will work in this case. But
Click to see outputoutput:
|
Ahhhh. Thank you @Fuud that makes sense. Thank you for clarifying! |
Use case
There is old issue: #45
Main problem:
ObjectMapper.treeToValue
looks very similar toObjectMapper.readValue
but suffers from type erasure.It is very simple to missuse it.
Current behaviour is because
ObjectMapper.treeToValue(TreeNode, TypeReference)
does not exist.As suggested in FasterXML/jackson-databind#1294 we can use readValue or convertValue.
Describe the solution you'd like
Let's either:
ObjectMapper.treeToValue
in type-safe wayThe text was updated successfully, but these errors were encountered: