There is a need to have top-level serializer extension properties named list, set, and map that construct build-in collection serializers from the element serializers with the following signatures:
val <T> KSerializer<T>.list: KSerializer<List<T>>
val <T> KSerializer<T>.set: KSerializer<Set<T>>
val <K, V> Pair<KSerializer<K>, KSerializer<V>>.map: KSerializer<Map<K, V>>
So, a list of serializable Data items received via REST API in str: String could be deserialized conveniently with:
val list = JSON.parse(str, Data.list) // inferred type of list is List<Data>
Implemented.
The test case shows how to use it with custom serializers, but how can we use it with a list of objects using the default serializer from @Serializable?
You can get your List/Set... serializer from the default serializer of class Foo with Foo.class.serializer().list
Most helpful comment
You can get your List/Set... serializer from the default serializer of class Foo with
Foo.class.serializer().list