-
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
Cannot use value class as map key in 2.17 #777
Comments
I am positively considering adding this feature. It will be basically the same usability as deserialization of However, I am busy and sick, so it may take some time until I can merge it into @cowtowncoder I don't believe there is a Also, are there any caveats about searching for another I am assuming that this is a very limited edge case, but I am assuming that there are nested types that require a special deserialization method. |
Just to clarify, previous versions of jackson don't exhibit errors when using value classes as keys in maps. As such, I think this should be labeled as a bug and not an enhancement. |
@junkdog It is still possible to deserialize a For these reasons, I interpret this as a feature request. |
Maybe the difference here is wrt serialization (where "value.toString()" is used for "unknown" types) vs deserialization (where exception will be thrown)? |
No I don't think so; except for
Not sure; in general ideally would be resolved earlier and not during reading (in fact, it really should be done during construction/resolution for deserialization; sometimes not doable for serialization). But other than that I suspect it should be fine. |
Is this not a function for |
I will not implement this feature in I am unable to work on a fix as my busy state has become rather worse. |
No, as name implies, it is for JSON values -- keys are specifically separate thing (from Jackson perspective), key names for But there are also other relevant annotations: |
Search before asking
Describe the bug
Jackson 2.17 introduced support for deserializing value classes. However, using a value class as a key in a map still fails on deserialization.
To Reproduce
Throws:
Expected behavior
When deserializing a map
Map<MyValueClass, Any>
whereMyValueClass
wraps a supported primitive, the map should deserialize without throwing an error.Versions
Kotlin: 1.9.22
Jackson-module-kotlin: 2.17.0
Jackson-databind: 2.17.0
Additional context
No response
The text was updated successfully, but these errors were encountered: