I'm using this kind of map `customSerializers: Map...
# serialization
r
I'm using this kind of map
customSerializers: Map<KClass<*>, KSerializer<*>>
. In 0.20.0 I've used this function, which is now deprecated:
Copy code
@Deprecated(
    level = DeprecationLevel.ERROR,
    message = "This method was removed during serialization 1.0 API stabilization, " +
            "please use SerializersModule builder instead" // No replacement deliberately
)
public fun serializersModuleOf(map: Map<KClass<*>, KSerializer<*>>): SerializersModule = noImpl()
How to use SerializersModule builder to create a SerializersModule from my customSerializers map?
I've tried this:
Copy code
Json {
                    serializersModule = SerializersModule {
                        customSerializers?.map {
                            contextual(it.key, it.value)
                        }
                    }
                }
but it does not compile.
The function was implemented this way in 0.20:
Copy code
map.forEach { (kclass, serializer) -> contextual(kclass as KClass<Any>, serializer.cast()) }
But what was
.cast()
method/function doing? It's not available now.
Should I just cast serializer as
KSerializer<Any>
?
s
Yes, it should work that way
🙏 1