Replies: 2 comments
-
Jackson uses separate Key Serializers and Deserializers to handle the keys of Maps. Please have a read of https://www.baeldung.com/jackson-map |
Beta Was this translation helpful? Give feedback.
0 replies
-
@pjfanning thanks for quick reply, tried this and it worked. Thanks again |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Search before asking
Describe the bug
Context
Wanted to use Jackson Databind to convert a
Map<Duration, UUID>
into a JSON string. But object mapper should use custom serde methods instead of the defaultDuration::toString
. Therefore, created few serde implementations, added it to a module and registered that module with a object mapper (GithubSnippet::main
onL67
). Further created 2 objects:Input Cases
Current / Expected Behavior
Converting
input1
into a JSON string gives output{"00000000-0000-0000-0000-000000000000":"12345ms"}
which is expected. Whereas convertinginput2
into a JSON string gives incorrect output{"PT12.345S":"00000000-0000-0000-0000-000000000000"}
( expected{"12345ms":"00000000-0000-0000-0000-000000000000"}
)Snippet
Version Information
2.17.2
Beta Was this translation helpful? Give feedback.
All reactions