-
Notifications
You must be signed in to change notification settings - Fork 637
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
Provide an API to build serial descriptors for recursive data-structures. #2915
Comments
In addition it would be good to make sure that the library (and all formats) work correctly with user provided serial descriptor implementations. In terms of the general solution, it would be good if the solution could be properly self-referential (rather than having lazily generated copies). This may be mainly the documentation of preferring |
Not sure I follow here, could you please elaborate on the idea?
This part, I think, we'll be extensively covered by tests (and the whole approach is more or less battle-tested with
The caveat here is that all intermediate serializers have to be aware of that.
it is s |
I suspect it works already (due to |
👍🏿 |
Ok |
Consider the following class:
For that,
kotlinx.serialization
is able to generate a proper serializer (using the coupling between auto-generated serializer andchildSerializers
loophole), but there is no public API to write it an external (or custom) serial descriptor/serializer for that.When solving the similar problem for
JsonElement
serialization, we ended up with the following:kotlinx.serialization/formats/json/commonMain/src/kotlinx/serialization/json/JsonElementSerializers.kt
Lines 219 to 235 in 776e3c1
Potentially, we can streamline it, pick a decent name (e.g.:
recursive
,deferred
,nested
) and make it publicThe text was updated successfully, but these errors were encountered: