'Kotlin json serialization, list with any value

I have the following data class which I'm trying to serialize.

@Serializable
data class QueryResponseDto(
val results: List<Result>
) {
@Serializable(with = Result.PacketSerializer::class)
data class Result(
    val columns: List<String>,
    val types: List<String>,
    val values: List<List<@Contextual Any>>
)
}

This is the form of my json.

{"results":[{"columns":["id","name"],"types":["int","varchar"],"values":[[1,"Store one"]]}]}

Is this achievable using the serialization? I have no idea of how to make the serializer builder for the 2D Any array.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source