```class ShapeTypeAdapter: TypeAdapter<Shape&gt...
# klaxon
b
Copy code
class ShapeTypeAdapter: TypeAdapter<Shape> {
    override fun classFor(type: Any): KClass<out Shape> = when(type as Int) {
        1 -> Rectangle::class
        2 -> Circle::class
        else -> throw IllegalArgumentException("Unknown type: $type")
    }
}
a
You can pass
{}
a lambda instead throwing an exception, for caching the exception you can do that whereever you parse the object
👍🏾 2
b
Thx!