Thread
#serialization
    t

    Tomas Kormanak

    1 year ago
    Hi, is there a way how to deserialize dynamic structure from JSON? For example I have this class but I don't know the exact structure of
    data
    property.
    @Serializable
    data class Sample(
        val name:String,
        val data: Any
    )
    Jérôme Gully

    Jérôme Gully

    1 year ago
    I don't know if it's what you search, but you can try to use JsonElement :
    Json.parseToJsonElement(sample).jsonObject["data"]
    https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md#json-elements