encodeToMap

fun <T> encodeToMap(serializer: SerializationStrategy<T>, value: T): Map<String, Any>

Encodes properties from the given value to a map using the given serializer. null values are omitted from the output.