generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 19
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
@JsonSubTypes does not work as a field annotation #536
Labels
type: improvement
A minor improvement to an existing feature
Comments
I think this is a Micronaut Serialization not a Micronaut Problem JSON issue right? |
yawkat
added a commit
that referenced
this issue
Nov 2, 2023
SerdeImport does not add the Serdeable.Deserializable stereotype so findSubtypeDeserializables would not include an imported type in the subtype listing. This PR overrides findSubtypeDeserializables to use isEnabledForDeserialization which handles import properly. This is for #536, not sure it fixes the full issue though.
sdelamo
pushed a commit
that referenced
this issue
Nov 2, 2023
SerdeImport does not add the Serdeable.Deserializable stereotype so findSubtypeDeserializables would not include an imported type in the subtype listing. This PR overrides findSubtypeDeserializables to use isEnabledForDeserialization which handles import properly. This is for #536, not sure it fixes the full issue though.
There is one remaining issue here, we don't support type info annotations on properties like here: https://github.com/vtyro/jackson-serde/blob/master/src/main/java/com/example/err4/Model4.java I will rename this issue and mark it as improvement, though the #634 was a bug. |
yawkat
added
type: improvement
A minor improvement to an existing feature
and removed
type: bug
Something isn't working
labels
Nov 3, 2023
yawkat
changed the title
Micronaut Serde error when using @JsonSubTypes
@JsonSubTypes does not work as a field annotation
Nov 3, 2023
Fixed by #705 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior
JSON Serialization/Deserialization of @JsonSubTypes with @SerdeImport for implementation class and generic field should work correctly.
Actual Behaviour
When I use @JsonSubTypes for interface or abstract class and use @SerdeImport for implementation class, than deserializer throw error:
Error decoding JSON stream for type [interFace]: Unable to deserialize type [InterFace]: No default constructor exists io.micronaut.http.codec.CodecException: Error decoding JSON stream for type [interFace]: Unable to deserialize type [InterFace]: No default constructor exists at app//io.micronaut.json.codec.MapperMediaTypeCodec.decode(MapperMediaTypeCodec.java:170) at app//io.micronaut.http.codec.MediaTypeCodec.decode(MediaTypeCodec.java:143) at app//io.micronaut.http.codec.MediaTypeCodec.decode(MediaTypeCodec.java:210) at app//com.example.JacksonSerdeTest.testSerdeImportDeserializeErr1(JacksonSerdeTest.java:43)
It's ok if I using @Serdeable annotation. Another problem with Deserialize when using generic field: data is lost.
Steps To Reproduce
I create simple example in gitlab.
Environment Information
No response
Example Application
https://github.com/vtyro/jackson-serde
Version
4.0.0
The text was updated successfully, but these errors were encountered: