What is the best way to detect specific unboxed (primitive) arrays in kotlinx-serialization?

Hi all,

I’ve been working on a custom kotlinx-serialization format for a while now. Currently, I’m looking for a good way to detect primitive array types in the encoding process. The problem is:

  • KXS handles all collection-like formats as StructureKind.LIST, which is fine so far because it handles the serialization / deserialization from / into the actual type for you.
  • The format I’m implementing has dedicated types for Byte, Int and Long Arrays.
  • Therefore, I’d like to treat StructureKind.LIST elements differently if they are actually representing one of ByteArray, IntArray and LongArray.

So: What is the best way to get that kind of information out of a SerialDescriptor?

Thank you!

1 Like