is there any documentation or guide on serial descriptors because they just make no sense to me. I don't understand what they're used for and i have no idea what to put for when im making a custom serializer
04/20/2023, 9:28 AM
Could you describe your problem more clearly? Like which part you don't understand about custom descriptors. I think the class documentation is good enough.
`SerialDescriptor`s are mainly for metadata, describing the structure of the corresponding class, which is then used to determine how to encode/decode (aside from
04/20/2023, 9:34 AM
I think @zt is trying to ask
how does one code a serial descriptor while creating a custom serializer. There are multiple kinds/forms/representations of descriptors and it is slightly hard to know which serializer takes which form
I do not have enough knowledge to answer him, but I do understand his question.
04/20/2023, 11:45 PM
Not a full answer, but the descriptors completely describe the shape of the data for the encoder/decoder. The encoder/decoder don't actually look at the value itself (the value being serialized) when deciding how to write/read. (Except for contextual maybe, but don't worry about that)
So basically an encoder gets a value, and asks the descriptor "hey, what am I looking at?". and based on the element name/index/kind/etc. it can figure out what to do.
As for how to create the descriptor... yeah I agree there can definitely be clearer documentation (which is a tough task for such a complicated API/library, and probably why the class/method docs are so technical instead of intuitive). I usually poke through the docs, and for anything more complicated than class serializers (list, maps, polymorphic, ...), I poke through serializers in the kotlinx.serialization source to see how they're written
There are a bunch of utility functions, like buildClassSerialDescriptor that are documented well and provide good examples how to use them. (Though not necessarily the why, or what their purpose is