Skip to content

How to deserialize List<Any>? #478

Closed Answered by StefMa
StefMa asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the reply @charleskorn!
That pushed us into the right direction I guess.
We finally managed to have a nice License object that contains a Info object 🥳
We just have to a "second" SerialDescriptor to the LicenseEntrySerializer that is able to deserialize the Info object:

class LicenseEntrySerializer: KSerializer<List<String>> {
    override val descriptor: SerialDescriptor = ListSerializer(String.serializer()).descriptor
    // Added the "child" SerialDescriptor
    private val infoMapDescriptor: SerialDescriptor = ListSerializer(Info.serializer()).descriptor

    override fun deserialize(decoder: Decoder): LicenseEntry {
        // Code from above..
        // Use the new MapDe…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@StefMa
Comment options

Answer selected by StefMa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants