-
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
MismatchedInputException: Cannot construct instance when deserialising class with inline field #187
Comments
I have the same issue. |
any news on this issue?
Inline classes are still not "released" but why is there issues to read from json? |
has anyone found a workaround to this? |
a no-arg constructor seems to do the trick, but it's not really a satisfactory workaround in our case |
Thank you! It's worked. |
I found this (although might not work in Kotlin) https://stackoverflow.com/questions/55529028/jackson-deserialization-error-mismatchedinputexception . Basically adding the annotation @JsonCreator to the inline class Name might work |
Interesting, I wonder if that annotation causes the Kotlin compiler to generate different bytecode such that the constructor is available for introspection at runtime. I think looking into that would be a good step towards finding a solution for supporting inline classes. |
This issue is closed as the issue regarding deserialization support for |
I've been playing around with Kotlin 1.3 features, and decided to give inline classes a try. With Kotlin 1.3M2 it was possible to serialise and deserialise classes with fields that are inline classes. I just tried them again with Kotlin 1.3 final (1.3.0), and noticed that deserialisation no longer works (serialisation is okay). The Kotlin 1.3 RC release notes mention a change in the binary representation of inline classes, so I guess that could be the root cause.
I've put together a minimal test class to illustrate:
--
If you run this, the test will fail on when calling 'objectMapper.readValue':
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of 'Person' (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (String)"{"name":"Mark"}"; line: 1, column: 2]
The text was updated successfully, but these errors were encountered: