Is it possible to have a convenience class to generate data classes from Dictionary/Document with annotation processing/KAPT?

Basically I want an easy way to do this:

Let’s say I have a data class that corresponds to a Couchbase document e.g.:

data class DataClassDerivedFromCouchbaseDocument(
    @SerialName("item_id") val id: Int,
    @SerialName("product_code") val code: String,
    @SerialName("item_description") val description: String

Where the Document is like this:
{"item_id": 234235235, "product_code": "AKDNADJA", "description": "Product Number 2343"}

Is it possible to have something like:

inline fun <reified T> deserialize(document: Document): T {
    return document.deserialize(

fun main() {
    val document = database.getDocument("test")
    val dataClass: DataClassDerivedFromCouchbaseDocument  = document.deserialize()
    // OR
    val dataClass  = document.deserialize<DataClassDerivedFromCouchbaseDocument>()
    // OR
    val dataClass  = document.deserialize(
    assert(document.getInt("item_id") ==
    assert(document.getString("product_code") == dataClass.code)
    assert(document.getString("item_description") == dataClass.description)

This would save a lot of time to developers. You can also give the option to ignore the values that are not specified in the data class like what KotlinX Serialization does.

I know, right?

Surely this is possible. We haven’t done it yet. If you have a shot at it and need any changes in the platform code, to make it work please let me know.

I would LOVE to see this happen.