-
Notifications
You must be signed in to change notification settings - Fork 624
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
How can I have serializer for a full hierarchy of classes without needing deserialization ? #1868
Comments
Unfortunately sealed interface serialization isn't released yet (see #1576). It depends on the compiler plugin to support this, which will likely be in 1.6.20 (it may already be in -M1, it has been implemented). |
But I have the same error when putting the root interface as sealed class. Should I try with 1.6.20-M1 then ? |
Can you try with 1.6.20-M1, please? However,
shouldn't happen on the current version. Are you sure about this and have a reproducer? |
Hi again, sorry to reply only now but here's a repo in a branch where it doesn't work, the master branch works and is pretty much the same thing. |
@Ayfri I noticed you're also using compose in the same project. There are known conflicts between compose and kotlinx.serialization. It may be worthwhile to try out the serialization code in a proof-of-concept (or separate module) that does not have the compose/UI code (that tends to be a good design approach as well). |
Is it still actual? |
Hi, I have a project with a lot of simple classes, but they differ a lot and there are like 50 classes in total (but they might be a lot more in the future).
The root is a sealed interface without any properties, the second layer contains 3 sealed classes and the next layers contains a lot of different classes with different fields, so I can't really use
JsonContentPolymorphicSerializer
.Also, some fields requires custom serializers because I'm using Compose Desktop to I have a custom serializer for
MutableState
,SnapshotListState
andSnapshotMapState
. There are other little custom serializer for lower casing value etc.Using only
@Serializable
and only sealed classes, I still come up with an error when trying to serialize any of the bottom-layer classes, with every time the errorDo you have any solution for this ? I might look for GSON if not ¯_(ツ)_/¯
The text was updated successfully, but these errors were encountered: