You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I.e., decoding drops all items of the collection but the last.
Notes
Using a standard "collection" (List, Set, Array, etc.) for the shopping cart directly instead of a class with a delegated serializer results in the decoding working as expected.
Changing the custom serializer's implementation to delegate to SetSerializer or any other "built-in" collection serializer results in the same incorrect behaviour.
The custom serializer's deserialize function is called once for each item of the collection, instead of only being called once for the whole collection.
The kotlinx.serialization JSON serializer has no problems with this example.
The text was updated successfully, but these errors were encountered:
YarnSphere
changed the title
Values serialized as a collection via a custom serializer aren't decoded correctly
Values serialized as collections via custom serializers aren't decoded correctly
Jun 8, 2024
Unfortunately this cannot work currently as list deserialization explicitly uses the AbstractCollectionSerializer to handle incremental reading of list elements. To avoid that the deserializer would need to buffer all list entries and only provide them at the end, as list.
Description
Consider the following toy example:
Where
ShoppingCartSerializer
is a custom serializer, which serializesShoppingCart
as a list:The following test, which should pass, does not:
The first assert passes, i.e., encoding is correct.
The second assert, however, fails with:
I.e., decoding drops all items of the collection but the last.
Notes
List
,Set
,Array
, etc.) for the shopping cart directly instead of a class with a delegated serializer results in the decoding working as expected.SetSerializer
or any other "built-in" collection serializer results in the same incorrect behaviour.deserialize
function is called once for each item of the collection, instead of only being called once for the whole collection.Reproduction
The code above showcasing the issue is available at: https://github.com/YarnSphere/xmlutil-custom-collection-serialization
Versions tested
0.86.3
with Kotlin1.9.24
0.90.0-RC2
with Kotiln2.0.0
The text was updated successfully, but these errors were encountered: