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
Support serialization of collections that are not lists #1821
Conversation
584045c
to
bb65e84
Compare
4d65726
to
43fc8b2
Compare
So far there was an implicit assumption hard-coded that collections are always lists. However, sets are also collections, and can be serialized to JSON arrays just like lists. This change allows to serialize generic collections independently of the concrete implementation. Fixes Kotlin#1421.
Now with `CollectionSerializer` inheriting from `ListLikeSerializer`, it makes sense to rename `ListLikeSerializer` to the more generic `CollectionLikeSerializer`.
43fc8b2
to
ed99652
Compare
Reviews anyone? @sandwwraith maybe? |
@sschuberth Sorry, I was on vacation. I'll return to your PR in a couple of days. |
core/commonMain/src/kotlinx/serialization/internal/CollectionSerializers.kt
Show resolved
Hide resolved
Please also execute |
Done by running `./gradlew apiDump`.
I've added a new commit that updates the API dump for all introduced changes at once, I hope that's fine. Let me know if you want API dump changes squashed into the commit that do the actual changes instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, great job!
Oops. I've just realized that this PR is opened against |
So far there was an implicit assumption hard-coded that collections are always lists. However, sets are also collections, and can be serialized to JSON arrays just like lists. This change allows serializing generic collections independently of the concrete implementation. Fixes #1421. * CollectionSerializers: Remove redundant visibility modifiers * SealedGenericClassesTest: Remove unused variables to avoid warnings * Rename `ListLikeSerializer` to `CollectionLikeSerializer` Now with `CollectionSerializer` inheriting from `ListLikeSerializer`, it makes sense to rename `ListLikeSerializer` to the more generic `CollectionLikeSerializer`. (cherry picked from commit d254e6d)
So far there was an implicit assumption hard-coded that collections are
always lists. However, sets are also collections, and can be serialized
to JSON arrays just like lists.
This change allows to serialize generic collections independently of the
concrete implementation.
Fixes #1421.