Hello Everyone, I am using a model for parsing jso...
# multiplatform
r
Hello Everyone, I am using a model for parsing json response in common main module of Kmp:
Copy code
@Serializable
data class Action(
    val type: String? = "",
    @SerialName("options") val options: Map<String,@Contextual Any>? = null
)
I am getting below exception when parsing : Exception occurred during parsing: Error parsing JSON: Serializer for class 'Any' is not found. Mark the class as @Serializable or provide the serializer explicitly. org.opentest4j.AssertionFailedError: Exception occurred during parsing: Error parsing JSON: Serializer for class 'Any' is not found. Any help will be appreciated.
can anyone help here?
v
There are multiple ways to make it work. One way - to use the polymorfic Serialization to inform how it supposed to deserialize your polymorphic data. Although your "Any" makes not sense. Another way would be to define it as JsonElement instead of any, and then manually deserialize it to correct type depends on the type.