toMap
Converts this object to a MutableMap representation.
Uses the pre-configured JsonSerializer to convert the object to a map with String keys and Any values. This is useful for generic access to object properties or for serialization purposes.
Receiver
The object to convert to a map.
Return
A MutableMap containing all properties of the object with their string keys.
Parameters
T
The type of the object being converted.
Throws
JsonProcessingException
if conversion fails.
Example:
data class User(val name: String, val age: Int)
val user = User("John", 30)
val map = user.toMap()
println(map["name"]) // "John"
println(map["age"]) // 30Content copied to clipboard