Metuuu
5/9/2019 - 5:50 AM

MapToString and vice versa

fun mapToString(map: Map<String, String>): String {
    val arrayOfMapEntries = map.entries.map { entry ->
        entry.key + "=" + entry.value
    }
    return arrayOfMapEntries.joinToString(",")
}
fun stringToMap(s: String): Map<String, String> {
    val map = s.split(",").associate {
        val (left, right) = it.split("=")
        left to right
    }
    return map
}