unbox
value class
in Collection
etc. when serializing
#468
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for #464.
Currently,
getter
/field
forvalue class
returnsunboxed
content, but not if it is contained in aCollection
orArray
.So I added a serializer to
KotlinSerializers
thatunboxes
the content (the details of the process are commented).And also added tests for various situations.
About
unbox
processing ofkey
.I have not yet worked on the
unbox
handling ofkey
inMap
.If there are no problems with this
PR
, I will try to address it in anotherPR
.Although ignored as a test case, serialization of
value
inMap
has already been addressed as of this PR.Known Issue
Currently, in
Jackson
, when multipleSerializer
/Serializers
are registered inObjectMapper
, the later registeredSerializer
seems to have priority.Therefore, if a user registers a
Module
before aKotlinModule
, the addedValueClassUnboxSerializer
will have priority over the user-definedSerializer
.I was not able to solve this problem.
However, as far as I read
Extentions.kt
and so on, I think I can ignore this problem becauseKotlinModule
is the first one to be registered in normal use cases.Is there any problem with this policy?
Repletion
In the following comment, I wrote about my concern about the behavior when
JsonValue
is given, but it seems to be unfounded.#464 (comment)
Jackson
overrides the annotations given to classes or fields.FasterXML/jackson-databind#586