-
Notifications
You must be signed in to change notification settings - Fork 173
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
Unsafe, not typed result of treeToValue method. #45
Comments
What generics are you applying to And |
Sorry, I forgot about code style, so generics looks like tag and didn't appears in message. I fixed it. |
yes, you can't use that method, it ignores the generics. if you look at the java method it passes in a class and not a type. so change to the other methods as I mentioned and they should work. |
I can change the extension function in the future to do the work around since Kotlin version doesn't see the internal detail of type erasure because that parameter is hidden. |
but for now that readValue work around is the same functionality |
Thank you, it would be great. |
Let me know if the work around works for you, and I'll include it next time I do a round of dev. |
closing, shouldn't be an issue. |
Sample code:
val listOfPojo:List<POJO> = jsonMapper.treeToValue(jsonNode)
Return
List<LinkedHashMap>
instead ofList<POJO>
. After iterration have java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to POJO.Works OK:
val listOfPojo<POJO> = jsonMapper.readValue(jsonNode.toString())
The text was updated successfully, but these errors were encountered: