Moshi + Kotlin + SealedClass
问题 Is there a way of deserializing json using sealed class Layer data class ShapeLayer(var type: LayerType) : Layer data class TextLayer(var type: LayerType) : Layer data class ImageLayer(var type: LayerType) : Layer LayerType is just some enum which can be used to distinguish which type should this object have. I thought I could add Adapter this way: class LayerAdapter{ @FromJson fun fromJson(layerJson: LayerJson): Layer { return when (layerJson.layerType) { LayerType.SHAPE -> PreCompLayer()