Skip to content
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

JsonDeserialize annotation does not work for value class that is unboxed on the argument #46

Closed
k163377 opened this issue Jan 19, 2023 · 1 comment · Fixed by #50 or #183
Closed
Labels
value class About value class support

Comments

@k163377
Copy link
Contributor

k163377 commented Jan 19, 2023

Fixes #50 and #54 make it work except for the JsonDeserialize annotation when it is unboxed on the argument.


Below is the initial description.

Annotation given to function arguments containing value class does not work

Annotations with value class as an argument are compiled into synthetic functions with markers and private functions without markers.
Jackson is handling the private function, but this function does not reflect the annotation given on Kotlin.
This prevents the associated content from working.

This problem can be avoided by modifying the annotations to be given to getter, etc.

// before
data class Data(@JsonSerialize(using = /* ... */) val value: ValueClass)

// fixed
data class Data(@get:JsonSerialize(using = /* ... */) val value: ValueClass)

As for the annotations that must be given as arguments, please wait until the problem is fixed.

k163377 added a commit that referenced this issue Jan 22, 2023
#46 fixed on serialize
k163377 added a commit that referenced this issue Jan 22, 2023
#46 fixed on serialize
k163377 added a commit that referenced this issue Jan 22, 2023
@k163377 k163377 reopened this Jan 22, 2023
k163377 added a commit that referenced this issue Jan 26, 2023
@k163377 k163377 changed the title Annotation given to function arguments containing value class does not work JsonDeserialize annotation does not work for value class that is unboxed` on the argument Jan 26, 2023
@k163377 k163377 changed the title JsonDeserialize annotation does not work for value class that is unboxed` on the argument JsonDeserialize annotation does not work for value class that is unboxed on the argument Jan 26, 2023
@k163377 k163377 added the value class About value class support label Feb 12, 2023
@abop
Copy link

abop commented Oct 18, 2023

Fixes #50 and #54 make it work except for the JsonDeserialize annotation when it is unboxed on the argument.

Below is the initial description.

Annotation given to function arguments containing value class does not work

Annotations with value class as an argument are compiled into synthetic functions with markers and private functions without markers. Jackson is handling the private function, but this function does not reflect the annotation given on Kotlin. This prevents the associated content from working.

This problem can be avoided by modifying the annotations to be given to getter, etc.

// before
data class Data(@JsonSerialize(using = /* ... */) val value: ValueClass)

// fixed
data class Data(@get:JsonSerialize(using = /* ... */) val value: ValueClass)

As for the annotations that must be given as arguments, please wait until the problem is fixed.

    data class SummaryInfoReq(
        @get:JsonProperty("currency") val currency: Currency,
        @get:JsonProperty("vendor_net_pay") val vendorNetPay: BigDecimal,
    )

The @JsonProperty annotation works as expected (both when serializing and deserializing) when given to getter. 👏

k163377 added a commit that referenced this issue Nov 25, 2023
…perties

This indicates that #46 has been resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
value class About value class support
Projects
None yet
2 participants